-
Notifications
You must be signed in to change notification settings - Fork 604
Unit Tests
kgibm edited this page May 15, 2018
·
10 revisions
Normally, code should be tested (explicitly or implicitly) by FAT tests which run test applications that access APIs exposed by configured features.
However, in some cases, it may be useful to write unit tests outside of the FAT infrastructure.
Unit tests are housed within the test
subfolder of a project.
-
Add to
.classpath
:<classpathentry kind="src" output="bin_test" path="test"/>
-
Add to
bnd.bnd
:-testpath: \ ../build.sharedResources/lib/junit/old/junit.jar;version=file
Different ways to run unit tests:
./gradlew com.ibm.ws.whatever:test
./gradlew com.ibm.ws.whatever:build
- In Eclipse, right-click on the
test
directory and select Run As > JUnit Test - If you want a code coverage report to be generated (in addition to running the unit tests), you can do
./gradlew com.ibm.ws.whatever:jacocoTestReport
- the report is output tocom.ibm.ws.whatever/build/libs/reports/jacoco/test/html/jacoco-sessions.html
If you need to add extra dependencies to your unit test classpath, do so via -testpath
in bnd.bnd instead of -buildpath
. Note that -buildpath
gets inherited into the -testpath
.