2016-06-22 17 views
0

Ich brauche Multi Reporter für Mocha zu verwenden, so dass ich wählen:Mokka Multi Reporter mit jUnit

https://github.com/stanleyhlng/mocha-multi-reporters

alles in Ordnung ist, aber ich brauche individuelle Reporter verwenden - Mokka-junit-Reporter.

Wie kann ich in Mocha-Multi-Reporter Mocha-Junit-Reporter verwenden?

ich so etwas wie dies versucht haben:

"junitReporterOptions": { 
     "id": "junit", 
     "reporter": "mocha-junit-reporter", 
     "output": "../../cms2/raportUnitTestsjunit.xml" 
    }, 

Aber ich habe "Reporter tut nicht gefunden junit!". Ist es kompatibel mit Mocha-Multi-Reportern?

Antwort

0

Sie können "[email protected]" installieren, um den benutzerdefinierten Reporter "mocha-junit-reporter" zu verwenden.

// File: config.json 
{ 
    "reporterEnabled": "mocha-junit-reporter", 
    "mochaJunitReporterReporterOptions": { 
     "mochaFile": "junit-custom.xml" 
    } 
} 

$ ./node_modules/.bin/mocha --reporter mocha-multi-reporters --reporter-options configFile=config.json 

1..4 
ok 1 mocha-test 1 sample test 1.1 
ok 2 mocha-test 1 sample test 1.2 
ok 3 mocha-test 2 sample test 2.1 
ok 4 mocha-test 2 sample test 2.2 # SKIP - 
# tests 3 
# pass 3 
# fail 0 

$ cat xunit-custom.xml 
<?xml version="1.0" encoding="UTF-8"?> 
<testsuites name="Mocha Tests" time="0.001" tests="4" failures="0" skipped="1"> 
    <testsuite name="Root Suite" timestamp="2016-10-30T02:27:54" tests="0" failures="0" time="0"> 
    </testsuite> 
    <testsuite name="mocha-test #1" timestamp="2016-10-30T02:27:54" tests="2" failures="0" time="0.001"> 
    <testcase name="mocha-test #1 sample test #1.1" time="0.001" classname="sample test #1.1"> 
    </testcase> 
    <testcase name="mocha-test #1 sample test #1.2" time="0" classname="sample test #1.2"> 
    </testcase> 
    </testsuite> 
    <testsuite name="mocha-test #2" timestamp="2016-10-30T02:27:54" tests="2" failures="0" time="0"> 
    <testcase name="mocha-test #2 sample test #2.1" time="0" classname="sample test #2.1"> 
    </testcase> 
    </testsuite> 
</testsuites> 

Sie können eine Demo-Projekt @https://github.com/stanleyhlng/mocha-multi-reporters-demo

Hope this finden!

Verwandte Themen