Hugh Desmond
Hugh Desmond

Reputation: 110

can't run multiple tests with adb

I can run my tests singularly using the following command:

C:\Google Drive\Testing>adb -s C4F12CC05723D6E shell am instrument -w -e class c
om.example.project.test.testcases.basictests.Test1 com.example.
project.test/android.support.test.runner.AndroidJUnitRunner

com.example.project.test.testcases.basictests.test1:.

Time: 23.807

OK (1 test)

But I can't get all tests in the suite to run:

C:\Google Drive\Testing>adb -s C4F12CC05723D6E shell am instrument -w com.example
.project.test/android.support.test.runner.AndroidJUnitRunner


Time: 0

OK (0 tests)

I get the same result for trying to run a package of tests.

The runner doesn't seem to complain or anything, it just thinks there are 0 tests, when there are several.

I have the same problem when running the tests in android studio, I can run a single test but not the full suite or a full package.

I'm using espresso 2 which uses the AndroidJUnitRunner.

The test package is in the same project as the application being tested. The core application activities including the main activity reside in com.example.project and the test package is a subpackage of this; com.example.project.test

How do I investigate this problem?

Upvotes: 0

Views: 1268

Answers (2)

Hugh Desmond
Hugh Desmond

Reputation: 110

I figured it out myself.

My problem in particular was the structure of my android project, the test package location was causing issues with the runner finding my tests, I moved them to src/androidTest/java/test and now I can run the full suite and full test packages.

Upvotes: 0

user1240878
user1240878

Reputation:

Looks like you're not providing a test class when attempting to run the suite.

As per the Android documentation.

To run all of the tests in the class UnitTests, enter:

$ adb shell am instrument -w \ -e class com.android.demo.app.tests.UnitTests \ com.android.demo.app.tests/android.test.InstrumentationTestRunner

You can also run subsets of test classes and entire classes combined.

To run all of the tests in UnitTests, and the testCamera method in FunctionTests, enter:

$ adb shell am instrument -w \ -e class com.android.demo.app.tests.UnitTests,com.android.demo.app.tests.FunctionTests#testCamera \ com.android.demo.app.tests/android.test.InstrumentationTestRunner

Upvotes: 0

Related Questions