如何嵌套Mocha在junit.xml中描述

时间:2018-10-31 13:31:16

标签: node.js jenkins junit mocha jenkins-plugins

我有一系列的摩卡测试,其中包括诸如以下的嵌套描述

describe('Tests.', () => {
  describe('Test Method 1', () => {
    it('should do x', () => {
      // test code
    });

    it('should do y', () => {
      // test code
    });
  });
  describe('Test Method 2', () => {
    it('should do x', () => {
      // test code
    });

    it('should do y', () => {
      // test code
    });
  });
});

我正在使用mocha-junit-reporter生成看起来像这样的junit.xml

<testsuite name="Root Suite Tests." failures="0" time="0"> </testsuite>
<testsuite name="Root Suite Tests. Test Method 1" failures="0" time="0">
  <testcase name="should do x" time="0" classname="Tests. Test Method 1 should do x"> 
  </testcase>
  <testcase name="should do y" time="0" classname="Tests. Test Method 1 should do y"> 
  </testcase>
</testsuite>
<testsuite name="Root Suite Tests. Test Method 1" failures="0" time="0">...</testsuite>
<testsuite name="Root Suite Tests. Test Method 2" failures="0" time="0">
  <testcase name="should do x" time="0" classname="Tests. Test Method 2 should do x"> 
  </testcase>
  <testcase name="should do y" time="0" classname="Tests. Test Method 2 should do y"> 
  </testcase>
</testsuite>
<testsuite name="Root Suite Tests. Test Method 2" failures="0" time="0">...</testsuite>

mocha-junit-reporter的选项是

"useFullSuiteTitle": true,
"testCaseSwitchClassnameAndName": true

使用“测试结果分析器”插件在Jenkins中显示JUnit.xml时,显示如下

  

测试

 Test Method 1 should do x

 Test Method 1 should do y    

 Test Method 2 should do x    

 Test Method 2 should do y

我希望它像这样显示

  

测试

 Test Method 1 

      should do x

      should do y 

 Test Method 2 

      should do x 

      should do y

这可能吗?如果可能的话,我需要做些什么?

0 个答案:

没有答案