Technologies
Robolectric for unit testing
Powermockito for mocking
Jacoco for code coverage
Travis for CI
Coveralls.io for viewing coverage reports
...
Sample Class used for the unit tests is
org.ei.opensrp.path.activity.ChildDetailTabbedActivityUnitTest
Most tests should extend a BaseUnitTest, reusable methods can be added there
...
Examples are in this package.
Opensrp-client.opensrp-path.src.test.java.shared.customshadows
To use in a test simply include in the shadow class in the @Config Annotation of your Test Class at the class level. Checkout ChildDetailTabbedActivityUnitTest.java
Travis CI is configured to execute the tests on each commit, the feedback can be quickly viewed on slack’s opensrp-client channel as to whether the tests passed(from your commit)
To check out the Travis builds just got to
https://travis-ci.org/OpenSRP/opensrp-client/builds
The code coverage reports are also pushed automatically to coveralls, you can view them by going to this link
https://coveralls.io/github/OpenSRP/opensrp-client
Coveralls Color code.
If after a commit the coverall shows Green then it increased the code coverage
If it shows Gray the code coverage was retained
...
In order to execute the tests locally on your dev machine and generate a coverage report just do a
gradle jacocoTestReport
After running this a code coverage report will be generated on you workstation in the paths directory under the reports folder. That is
/opensrp-client/opensrp-path/reports/jacoco/html
Clicking on this file /opensrp-client/opensrp-path/reports/jacoco/html should open on your browser the current code coverage reports per class.
...
The gradle task task is defined in paths build.gradle file
If you want more info or debug or stacktrace incase of error just add the usual flags --info and --debug, i.e. runrun
gradle jacocoTestReport --info --stacktrace
Also checkout the gotchas here