-
Notifications
You must be signed in to change notification settings - Fork 420
Programming jSQL
💉jSQL
runs on 28k lines of code that can break when code is added therefore it requires tests to prevent regressions.
- Unit tests run and process stops if any failure is detected
- Then integration tests run, and process also stops if any test fails
- Finally a new version is released if all tests pass
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 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 withModel
- the injection
Model
runs withJUnit
testing framework and callsSpring
APIs - the
Spring
Web server API and pages are connected to the databases - the databases are
in-memory
and on🐳 Docker
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.
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 |
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)
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 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
.
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