When using flavours in an Android Gradle project, NBAndroid's Run->Test Project fails to execute any tests, as the Gradle task name, i.e. target, is invalid.
Executing: gradle assembleDebug assembleDebugTest FAILURE: Build failed with an exception. * What went wrong: Task 'assembleDebugTest' not found in root project 'HelloFlavours'. * Try: Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED
The task list returned by gradle tasks from the command line confirms that assembleDebugTest is not present. Valid test tasks include the flavour name, e.g. assembleFreeDebugTest to test the free flavour. Note that there are no release build tests, from the empirical evidence.
I have created an example project to illustrate the problem, called HelloFlavours - attached. Please see the enclosed ReadMe file before using it. This project can be successfully compiled, run and tested from the command line as follows:
gradle installFreeDebug installFreeDebugTest adb shell am instrument -w com.awayteamsoftware.helloflavours.tests/.MyTestRunner
Please fix this. Thank you.
I have encountered a number of issues which I believe are related to this problem and can be demonstrated using the same example project. However, I will raise those as separate items and reference the HelloFlavours project, to give better clarity.