Issue
I have an espresso test suite class like this
package instrumentedtest;
import org.junit.ClassRule;
import org.junit.rules.ExternalResource;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses({
Test1.class,
Test2.class,
Test3.class
})
public class POSRuleSuite {
@ClassRule
public static ExternalResource testRule = new ExternalResource() {
@Override
protected void before() throws Throwable {
System.out.println("Testing starts.........");
}
@Override
protected void after() {
System.out.println("Testing ends.........");
}
};
}
I set up a Firebase test with this suite class in Android Studio. I launch this firebase test from Android Studio and it does work.
But I failed to execute the test when I launch it from command line with Gcloud command.
gcloud firebase test android run ^
--type instrumentation ^
--app POS.apk ^
--test POS-debug-androidTest.apk ^
--test-runner-class=org.junit.runners.Suite ^
--test-targets=instrumentedtest.POSRuleSuite ^
--device model=Nexus10,version=22,locale=en,orientation=landscape ^
--timeout 300s
Here is output
Uploading [POS.apk] to Firebase Test Lab...
Uploading [POS-debug-androidTest.apk] to Firebase Test Lab...
Raw results will be stored in your GCS bucket at [https://console.developers.google.com/storage/browser/test-lab-j9zwyqscmy0rw-k53tazzivjxvu/2017-10-19_14:25:20.055000_jPmA/]
ERROR: (gcloud.firebase.test.android.run) Http error while creating test matrix: ResponseError 400: Invalid test target for instrumentation test: instrumentedtest.POSRuleSuite
C:\git\POS>
Does anyone know how to get it work?
Any help is appreciated.
Solution
I found the reason, We have to inform the type of the test-targets. In this case the type is class. So that line should be in this way.
--test-targets="class instrumentedtest.POSRuleSuite"
You can also pass a string list with all yours targets, separated by comma, e.g.:
--test-targets="class instrumentedtest.POSRuleSuite,class instrumentedtest.AnotherRuleSuite"
Here the full request.
gcloud firebase test android run ^
--type instrumentation ^
--app POS.apk ^
--test POS-debug-androidTest.apk ^
--test-targets="class instrumentedtest.POSRuleSuite" ^
--device model=Nexus10,version=22,locale=en,orientation=landscape ^
--timeout 300s
Answered By - Sean Shi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.