Run unit tests of java module in Android project

#1

Hi there,
I have an android project with the app module app, it builds fine and the unit tests are run.
As a module of this project, I have a java library called core-sdk.

How can I add a step that runs the unit tests of said core-sdk?

I’ve tried adding a step “Android unit tests”, providing the module name, but no variant (as a java library doesn’t have variants). I would have expected running
./gradlew :core-sdk:test
but what was run was
./gradlew :core-sdk:testClasses
which is a valid task but doesn’t actually run the tests.

I also tried changing the existing “Android uni tests” step by removing the module and variant info, hoping it would result in
./gradlew test
which runs the tests of all modules, but it would still only run the app module tests.

0 Likes

#2

You can use Gradle Unit test step for that

1 Like

#3

Thanks, good tip.
Tried it but I get an error:

Issue with input: no GradlewPath parameter specified

although the logs show

Configs:

  • GradlewPath: ./gradlew

for an earlier step (install-missing-android-tools).
I left the input variables for the step untouched, as ./gradlew test should run the module tests also.

Any idea how to fix that?

Thanks in advance.

0 Likes

#4

Try to specify gradle wrapper path input value explicitly.
It looks like an earlier step uses that or some environment variable.

0 Likes

#5

Thanks, I tried explicitly putting . or ./gradlew as the gradlew wrapper path, to no avail (same error message). What would I put into the gradle wrapper path field exactly?

0 Likes

#6

Is ./gradlew (relative to $BITRISE_SOURCE_DIR) present and executable?

0 Likes

#7

I assume $BITRISE_SOURCE_DIR ist just the root level of the project? I haven’t set that explicitly.
gradlew is present and executable at the project root level.

0 Likes