This is an implementation of an Android Instrumentation executing unit tests based on TestNG (Java testing framework that is more suitable for integration and complex automation tests than JUnit).
Depending on your build system, your mileage might vary, but with
Gradle the only required changes to your build files
should be limited to adding our repository,
then declaring the dependency and modifying your testInstrumentationRunner
:
// TO BE UPLOADED
// TestNG dependency, remember to update to the latest version
dependencies {
androidTestCompile 'com.github.tarcv:android-testng:X.Y.Z'
}
// Android setup
android {
defaultConfig {
testInstrumentationRunner 'com.github.tarcv.androidtestng.TestNGRunner'
}
}
The runner will look for classes everywhere in your classpath - same as standard ASTL library
Unfortunately this is BROKEN on Android
Test suites can also be defined using a testng.xml
file from your assets
directory.
This is useful when tests do not reside in the standard application package
plus ....test
.
One caveat, though, is that the <package />
element does not work (yet),
as TestNG expects JAR files, while Android bundles everything into a DAX file.
For an example see the testng.xml
file
included alongside these sources.
In order to have access to the Android's application Context please use ASTL standard InstrumentationRegistry#getTargetContext.
In comparison with the original project Guice is absent here.
The options to enable some features on testing are same as adb instrument. Current supported options are as below:
- debug
coverage(currently removed)coverageFile(currently removed)
If you need to run tests from Android Studio, please use Android Tests Configuration.
Licensed under the Apache License version 2