如何使用配置的测试计划

时间:2018-02-08 09:03:22

标签: android-source cts

我已经查看了CTS中可用的已知故障测试计划,其中排除了已知失败的CTS测试。从那里我很清楚,您可以使用此XML选项排除测试:

 .....
 <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.DocumentsTest#testCreateNew" />
 <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.DocumentsTest#testCreateWebLink" />
 <option name="compatibility:exclude-filter" value="CtsAppSecurityHostTestCases android.appsecurity.cts.DocumentsTest#testEject" />
 .....

所以我创建了一个 my-known-failures.xml ,包含了我要排除的约100个测试。并在cts-suite.xml中包含我的 my-known-failures.xml ,如下所示。

<configuration description="Runs CTS as a suite">
 ...
<include name="my-known-failures" />

当我运行cts-suite.xml时,我使用以下命令启动它:

./${CTS_BIN} run commandAndExit cts-suite-automated --logcat-on-failure --bugreport-on-failure --screenshot-on-failure --log-level-display debug

该报告表明cts-tradefed框架已经完成了我的配置:

Excludes:[ .... CtsAppSecurityHostTestCases android.appsecurity.cts.DocumentsTest#testCreateNew,  CtsAppSecurityHostTestCases android.appsecurity.cts.DocumentsTest#testCreateWebLink, CtsAppSecurityHostTestCases android.appsecurity.cts.DocumentsTest#testEject ... ]

但是,看起来这些测试看起来确实已经执行了,因为在test_result.xml中我们看到测试用例已经给出了“失败”结果并且包含了栈跟踪:

<Test result="fail" name="testEjected">
    <Failure message="java.lang.AssertionError: Devices that claim to support adoptable storage must have adoptable media inserted during CTS to verify correct behavior">
      <StackTrace>java.lang.AssertionError: Devices that claim to support adoptable storage must have adoptable media inserted during CTS to verify correct behavior
    at android.appsecurity.cts.AdoptableHostTest.getAdoptionDisk(AdoptableHostTest.java:311)
    at android.appsecurity.cts.AdoptableHostTest.testEjected(AdoptableHostTest.java:251)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at junit.framework.TestCase.runTest(TestCase.java:176)
    at junit.framework.TestCase.runBare(TestCase.java:141)
    at com.android.tradefed.testtype.DeviceTestResult$1.protect(DeviceTestResult.java:90)
    at com.android.tradefed.testtype.DeviceTestResult.runProtected(DeviceTestResult.java:65)
    at com.android.tradefed.testtype.DeviceTestResult.run(DeviceTestResult.java:94)
    at junit.framework.TestCase.run(TestCase.java:129)
    at com.android.tradefed.testtype.DeviceTestCase.run(DeviceTestCase.java:183)
    at com.android.tradefed.testtype.JUnitRunUtil.runTest(JUnitRunUtil.java:55)
    at com.android.tradefed.testtype.JUnitRunUtil.runTest(JUnitRunUtil.java:38)
    at com.android.tradefed.testtype.DeviceTestCase.run(DeviceTestCase.java:148)
    at com.android.tradefed.testtype.HostTest.runRemoteTest(HostTest.java:463)
    at com.android.tradefed.testtype.HostTest.runTestClasses(HostTest.java:406)
    at com.android.tradefed.testtype.HostTest.run(HostTest.java:397)
    at com.android.compatibility.common.tradefed.testtype.JarHostTest.run(JarHostTest.java:142)
    at com.android.tradefed.testtype.suite.ModuleDefinition.run(ModuleDefinition.java:278)
    at com.android.tradefed.testtype.suite.ITestSuite.runSingleModule(ITestSuite.java:276)
    at com.android.tradefed.testtype.suite.ITestSuite.run(ITestSuite.java:225)
    at com.android.tradefed.invoker.TestInvocation.runTests(TestInvocation.java:793)
    at com.android.tradefed.invoker.TestInvocation.prepareAndRun(TestInvocation.java:476)
    at com.android.tradefed.invoker.TestInvocation.performInvocation(TestInvocation.java:330)
    at com.android.tradefed.invoker.TestInvocation.invoke(TestInvocation.java:921)
    at com.android.tradefed.command.CommandScheduler$InvocationThread.run(CommandScheduler.java:555)
</StackTrace>
    </Failure>

所以我很困惑。我知道cts-tradefed框架确实排除了已知失败计划的一些测试,但是当我尝试做同样的事情时它不能按预期工作。

是否可以对cts-suite.xml进行排除测试的测试计划?

谢谢!

1 个答案:

答案 0 :(得分:1)

是的,您可以通过使用cts traded中的子计划功能来实现。 尝试使用要运行的所有模块创建子计划xml文件,并在同一xml文件中提及要排除的测试用例。

命令:运行cts --subplan

注意:将此xml文件放在/ android-cts / subplans / folder中 默认情况下,subplans文件夹不存在,您可以手动创建它并提供适当的文件夹权限。