Run unit tests of java module in Android project

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.

You can use Gradle Unit test step for that

1 Like

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.

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

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?

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

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.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.