在Firebase测试实验室中如何执行指定的测试套件类

4
我有一个像这样的 Espresso 测试套件类。
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.........");
        }
    };
}

我在Android Studio中使用这个测试套件设置了一个Firebase测试。我从Android Studio启动这个Firebase测试,它可以正常工作。

enter image description here

但是当我使用Gcloud命令从命令行启动时,我未能执行测试。
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

这里是输出

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>

有人知道如何使其工作吗?

感激不尽任何帮助。

1个回答

7
我找到了原因,我们需要通知测试目标的类型。在这种情况下,类型是。所以那一行应该是这样的。
--test-targets="class instrumentedtest.POSRuleSuite"

您可以传递一个字符串列表,其中包含所有目标,用逗号分隔,例如:
--test-targets="class instrumentedtest.POSRuleSuite,class instrumentedtest.AnotherRuleSuite"

Firebase文档参考

这里是完整的请求。

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

以下是如何在指定的测试套件类中运行特定测试的方法:https://stackoverflow.com/a/55759800/2848676 - Michael Osofsky

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接