an example of junit test being run from java application
-
docker pull maven
- pulls the latestmaven
imagedocker run -it --name my-maven-container maven bash
interactively runs container based on this image and execute a command shell inside (in case this container is already runningdocker exec -it my-maven-container /bin/bash
) -
cd
- changes the active directory to one of the current user (supposed to beroot
) -
git clone https://github.com/ksiv/junit-run-from-application.git
- pulld repo to current folder.git
command is present in the latest image I checked with. -
cd junit-run-from-application
-
mvn package
- downloads all dependencies and compiles test class and our executable app -
run
java -classpath "./target/test-classes:/root/.m2/repository/org/junit/platform/junit-platform-engine/1.10.1/junit-platform-engine-1.10.1.jar:/root/.m2/repository/org/junit/platform/junit-platform-launcher/1.10.0/junit-platform-launcher-1.10.0.jar:/root/.m2/repository/org/junit/platform/junit-platform-commons/1.10.1/junit-platform-commons-1.10.1.jar:/root/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.10.1/junit-jupiter-engine-5.10.1.jar:/root/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.10.1/junit-jupiter-api-5.10.1.jar:/root/.m2/repository/org/junit/jupiter/junit-jupiter-params/5.10.1/junit-jupiter-params-5.10.1.jar:/root/.m2/repository/org/opentest4j/opentest4j/1.3.0/opentest4j-1.3.0.jar" example.runner a
this executes all tests tagged
a
from all test classes found in this case from test filedummyTest.java
changinga
tob
will execute all test taggedb