This build will always fail because it has 2 examples of failing tests: one because of a defect in the SUT (system under test), and one because of an error in the test itself.
- Simple hello world example
- Experience with Git source code management
- Building with SBT
- Automated unit testing with JUnit
- Continuous integration with GitHub Actions
- Java 17 SDK or later (Java 17 LTS release recommended)
- SBT
Without command-line arguments:
$ sbt run
With specific command-line arguments:
$ sbt "run arg1 arg2 arg3"
$ sbt test
$ sbt jacoco
If the tests pass, you will then see the coverage report on the console. In addition, you can view a formatted HTML version of report in a web browser.
If the tests don't pass, however, you should force the generation of the test coverage report:
$ sbt jacocoReport
In Gitpod, navigate to and open
target/scala-2.12/jacoco/report/html/index.html
then press the "show preview" button in the top right corner.
On macOS:
$ open target/scala-2.12/jacoco/report/html/index.html
On Linux:
$ xdg-open target/scala-2.12/jacoco/report/html/index.html
On Windows: please let me know if you know how to do this from the WSL command line. Otherwise you can open the index file in your web browser.
Note that the report will show 0% coverage as long as there are failing tests.
This allows passing command-line arguments directly:
On Linux or macOS:
$ sbt stage
$ ./target/universal/stage/bin/hello-java arg1 arg2 arg3
On Windows:
> sbt stage
> .\target\universal\stage\bin\hello-java arg1 arg2 arg3