Publish Test Results任务测试名称显示异常,请求协助排查
TRX测试报告测试名称显示异常排查
我的TRX文件包含3个测试用例,<UnitTestResult>节点中的测试名称各不相同,但在测试报告的Tests标签页里显示的测试名称完全一致;不过点击每个测试用例时,调用栈和错误信息是正确的。
以下是TRX文件中<Results>和<TestDefinitions>的代码片段:
<Results>部分
<Results> <UnitTestResult executionId="a009dca9-9a9c-45c6-966e-ce83b6a8f4d0" testId="c9427cd3-1949-4163-f8e9-3d620e7b7c04" testName="CampaignAdGroupCreationMSANAdCreatorSuite" computerName="71986a60c000008" duration="00:03:23.4530000" startTime="2022-11-17T00:20:46.3170000+00:00" endTime="2022-11-17T00:24:09.7700000+00:00" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" outcome="Failed" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" relativeResultsDirectory="a009dca9-9a9c-45c6-966e-ce83b6a8f4d0" /> <UnitTestResult executionId="f61b0324-afe2-4b5a-b48d-e6fc2dbee4b0" testId="178fc87e-7321-761c-6004-c0824a26eaa4" testName="CampaignAdGroupCreationMSANAdCreatorSuite.should be able to apply effect to image added to an ad in create campaign workflow" computerName="71986a60c000008" duration="00:01:52.7160000" startTime="2022-11-17T00:21:15.6250000+00:00" endTime="2022-11-17T00:23:08.3410000+00:00" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" outcome="Failed" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" relativeResultsDirectory="f61b0324-afe2-4b5a-b48d-e6fc2dbee4b0"> <UnitTestResult executionId="a5a4451b-675c-47ef-80f3-fba4a13c9b56" testId="5db0478b-94a4-a31f-ee72-883dbd15bb96" testName="CampaignAdGroupCreationMSANAdCreatorSuite.should be able to apply effect to image added to an ad in create adgroup workflow" computerName="71986a60c000008" duration="00:01:01.2260000" startTime="2022-11-17T00:23:08.3420000+00:00" endTime="2022-11-17T00:24:09.5680000+00:00" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" outcome="Failed" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" relativeResultsDirectory="a5a4451b-675c-47ef-80f3-fba4a13c9b56"> </Results>
<TestDefinitions>部分
<TestDefinitions> <UnitTest name="CampaignAdGroupCreationMSANAdCreatorSuite" storage="parentsuite" id="c9427cd3-1949-4163-f8e9-3d620e7b7c04"> <Execution id="a009dca9-9a9c-45c6-966e-ce83b6a8f4d0" /> <TestMethod codeBase="ParentSuite" adapterTypeName="executor://mochatestexecutor/" className="ParentSuite" name="CampaignAdGroupCreationMSANAdCreatorSuite" /> </UnitTest> <UnitTest name="CampaignAdGroupCreationMSANAdCreatorSuite" storage="campaign-adgroup-creation-selenium" id="178fc87e-7321-761c-6004-c0824a26eaa4"> <Execution id="f61b0324-afe2-4b5a-b48d-e6fc2dbee4b0" /> <TestMethod codeBase="campaign-adgroup-creation-selenium" adapterTypeName="executor://mochatestexecutor/" className="CampaignAdGroupCreationMSANAdCreatorSuite" name="should be able to apply effect to image added to an ad in create campaign workflow" /> </UnitTest> <UnitTest name="CampaignAdGroupCreationMSANAdCreatorSuite" storage="campaign-adgroup-creation-selenium" id="5db0478b-94a4-a31f-ee72-883dbd15bb96"> <Execution id="a5a4451b-675c-47ef-80f3-fba4a13c9b56" /> <TestMethod codeBase="campaign-adgroup-creation-selenium" adapterTypeName="executor://mochatestexecutor/" className="CampaignAdGroupCreationMSANAdCreatorSuite" name="should be able to apply effect to image added to an ad in create adgroup workflow" /> </UnitTest> </TestDefinitions>
问题原因
测试报告的Tests标签页通常优先读取<TestDefinitions>中<UnitTest>节点的name属性来显示测试名称,而非<UnitTestResult>的testName或<TestMethod>的name。当前三个<UnitTest>的name都设置为CampaignAdGroupCreationMSANAdCreatorSuite,导致显示重复。
修复方案
修改<TestDefinitions>中两个子测试的<UnitTest>节点name属性,设置为完整的测试名称,与<UnitTestResult>中的testName保持一致:
- 第二个测试的
<UnitTest>修改为:<UnitTest name="CampaignAdGroupCreationMSANAdCreatorSuite.should be able to apply effect to image added to an ad in create campaign workflow" storage="campaign-adgroup-creation-selenium" id="178fc87e-7321-761c-6004-c0824a26eaa4"> - 第三个测试的
<UnitTest>修改为:<UnitTest name="CampaignAdGroupCreationMSANAdCreatorSuite.should be able to apply effect to image added to an ad in create adgroup workflow" storage="campaign-adgroup-creation-selenium" id="5db0478b-94a4-a31f-ee72-883dbd15bb96">
第一个父套件的<UnitTest>``name保持不变即可,这样Tests标签页就能正确显示每个测试用例的名称。
内容的提问来源于stack exchange,提问作者Gavin Wang
相关产品推荐
相关产品推荐

