2013-09-22 3 views
6

Ist es möglich, nur ein Test von nodeunit Testdatei mit mehreren Tests auszuführen. Meine tests.js Datei:Lauf eines Test mit Namen aus einer Datei nodeunit

module.exports = { 
    test2: function (test) { 
     console.log ("test2") 
     test.done(); 
    }, 
    test1: function (test) { 
     console.log ("test1") 
     test.done(); 
    } 
}; 

ich alle Tests ausführen können:

$ nodeunit tests.js 

Aber ich will laufen nur test2 wie:

$ nodeunit tests.js test2 

Ist es möglich, ohne Datei spliting tests.js in 2 separate Dateien?

Antwort

6

Siehe nodeunit -h für die verfügbaren Optionen (Dies ist für Version 0.8.1):

Usage: nodeunit [options] testmodule1.js testfolder [...] 
Options: 

    --config FILE  the path to a JSON file with options 
    --reporter FILE optional path to a reporter file to customize the output 
    --list-reporters list available build-in reporters 
    -t name,   specify a test to run 
    -f fullname,  specify a specific test to run. fullname is built so: "outerGroup - .. - innerGroup - testName" 
    -h, --help  display this help and exit 
    -v, --version  output version information and exit 

So aus, dass die folgenden sollte das tun, was Sie wollen:

$ nodeunit tests.js -t test2 

zB :

$ nodeunit ./tests.js -t test2 

tests.js 
test2 
✔ test2 
Verwandte Themen