4

For last few days I am struggling with setting up a separate test module in gradle for Android project. I found how I can set up instrumentation tests inside my main project under instrumentationTest directory but I can't find a way how to do this in new module. My test module doesn't see sources from my main project.

This is a structure of the project:

MyProject/
 | settings.gradle
 + MainApp/
    | build.gradle
    | src/main/java/...
    | res
 + MainAppFunctionalTests/
    | build.gradle
    | src/instrumentTest/java/...

In my settings.gradle I have:

include ':MainApp', 'MainAppFunctionalTests'

In MainAppFunctionalTests's build.gradle I put:

compile project(':MainApp')

but my test project still doesn't see the sources from my main project. I don't want to have functional tests in main project because I would like to put there unit tests using Robolectric.

I will be glad for any help.

user2990759
  • 127
  • 1
  • 5

1 Answers1

0

It seems compile project() only create dependency for library project, not app project. You can run

gradle MainApp:androidDependencies

to see the output.

I am also looking for ways to build test apk separately.

Edit: For now I need to move the test source code , and use assembleTest to build the apk, then install the test apk via command line

cheng yang
  • 1,692
  • 3
  • 12
  • 21