10

I have a android project that has multiple library modules and I am trying to test a specific package that contains all modules.

I tried this command:

./gradlew -Dtest.single=com.moduleone* testProductionDebug

And it does not work: it doesn't execute the tests inside this module, but instead executes all the unit tests in the main project package class.

How do I test just the one module?

Toby Speight
  • 27,591
  • 48
  • 66
  • 103
Jono
  • 17,341
  • 48
  • 135
  • 217

2 Answers2

1

You can use test suits: https://developer.android.com/reference/junit/framework/TestSuite.html . Definition of a suit contains classes of tests you need

Alex Shutov
  • 3,217
  • 2
  • 13
  • 11
1

Assuming you're trying to execute a gradle task against a single module rather than the entire project, you can supply the name of the module in front of the task separated by a colon (module_name:task)

Per your question, this would look something like
./gradlew -Dtest.single=com.moduleone* your_library_module:testProductionDebug

This is a simple example, assuming you have a simple project setup. You can also find further reading on this in the gradle docs for executing a multi-project build

Brad
  • 513
  • 3
  • 8