2013-09-22 27 views
6

Chỉ có thể chạy một thử nghiệm từ tệp kiểm tra nodeunit với một số thử nghiệm. tests.js tập tin của tôi:chạy một thử nghiệm theo tên từ một tệp nodeunit

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

tôi có thể chạy tất cả các xét nghiệm:

$ nodeunit tests.js 

Nhưng tôi muốn chạy chỉ test2 như:

$ nodeunit tests.js test2 

Có thể không spliting tập tin tests.js thành 2 riêng biệt các tập tin?

Trả lời

6

Xem nodeunit -h cho các tùy chọn có sẵn (Điều này là dành cho phiên bản 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 

Vì vậy, từ đó sau nên làm những gì bạn muốn:

$ nodeunit tests.js -t test2 

ví dụ :

$ nodeunit ./tests.js -t test2 

tests.js 
test2 
✔ test2 
Các vấn đề liên quan