Skip to content

Programming jSQL

ron190 edited this page Jun 7, 2024 · 84 revisions

💉jSQL runs on 28k lines of code that can break when code is added therefore it requires tests to prevent regressions.

  1. Unit tests run and process stops if any failure is detected
  2. Then integration tests run, and process also stops if any test fails
  3. Finally a new version is released if all tests pass

Unit tests

Unit testing ensures that lines of code produce the expected result, it warns you when you break something while adding new code.

You run unit tests without any external resource, no database, no API, and you can inspect the lines of code that have been triggered during the tests by using the code coverage reports.

Untriggered code means either it's useless or it does not run as expected.


Integration tests

Integration testing checks that the components interact properly and validate that they access the expected external resources.

The following components must properly communicate during integration tests:

  • the View displays the GUI and interact with Model
  • the injection Model runs with JUnit testing framework and calls Spring APIs
  • the Spring Web server API and pages are connected to the databases
  • the databases are in-memory and on 🐳 Docker

Release

New releases are automatically uploaded to GitHub when all tests pass and when an administrator approves the release.

The new version is then available to download, also 3rd party platforms like Kali Linux and Packetstorm pull the release.


Generated documentation and metrics

Every time the code changes and the tests on both components are running fine then docs are auto-generated:

  • Code coverage to identify code not tested
  • Mutation coverage to identify conditions corner cases
  • Javadoc describing all the classes and methods
  • Surefire report to review unit tests with execution time
  • Failsafe report to review integration tests with execution time
  • dependency report listing available version updates
Code
Coverage
Mutation
Coverage
Javadoc Surefire Failsafe Dependencies
Model report report doc unit tests integration tests updates
View report report doc unit tests updates

3rd party documentation

External platforms are also triggered on commit and produce additional reports:

  • Sonar measures code complexity, duplication and code smell (report)
  • Codecov displays code coverage graphically (report)
  • Codacy processes additional quality rules (report)

Continuous integration

Running unit tests, running integration tests and releasing a new version is processed during CI/CD.

Libraries used for testing are Spring, Spock and Hibernate, and :octocat:GitHub Actions is the cloud platform that runs the entire process.

Non regression tests run databases in-memory and on 🐳 Docker and the GUI is tested on VNC screen with GitHub Actions.

Quality checks are then processed and stored on code quality platforms like Sonarcloud, Codecov, Codacy and Snyk.


Architecture

The following diagram shows the global 💉jSQL architecture, it describes the components that run on GitHub Actions during the CI/CD process:

graph
junit(JUnit Tests)
subgraph "jSQL Injection"
    gui(GUI)
    model("💉Model")
end
subgraph Spring
    apis([/api])
    admin([/admin-page])
end
subgraph Memory
    memory-other[("
        SQLite H2
        HSQLDB
        Derby
    ")]   
end
subgraph Docker
    subgraph Apache + PHP
        direction LR
        mysql[(MySQL)]
        shell(["/shell.php"])
        passwd(["/etc/passwd"])   
    end   
end
subgraph Docker2 [Docker]
    docker-other[("
        SQL Server
        PostgreSQL 
        Neo4j Db2
        Cubrid
    ")]   
end
gui -. "call" .-> shell
mysql -. create .-> shell
mysql -. read .-> passwd
junit -.-> gui
junit --> model
model & gui -.-> admin
model --> apis
apis --> Docker & Docker2 & Memory
Loading

Previous topic: Databases, Next topic: Test scripts
Clone this wiki locally