TarCV / android-testng

TestNG instrumentation library for Android

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TestNG runner for Android

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).

Usage

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'
  }
}

Packages

The runner will look for classes everywhere in your classpath - same as standard ASTL library

XML Suites

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.

Contexts

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.

Options

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.

License

Licensed under the Apache License version 2

About

TestNG instrumentation library for Android

License:Apache License 2.0


Languages

Language:Java 99.5%Language:Kotlin 0.5%