2015-02-03 9 views

risposta

7

Il flag --testcase può essere utilizzato dalla versione 0.6 per eseguire un singolo test dalla riga di comando, ad es.

nightwatch.js --test tests\demo.js --testcase "Test 1" 

Questo può essere fatto utilizzando test groups o test tags. Puoi anche eseguire un singolo test con il flag --test, ad es.

nightwatch.js --test tests\demo.js 
8

È necessario utilizzare tag specifici prima funzione e separata tutte le funzioni nei file diferent sotto Prove, e poi il comando chiamare con --tag argomento. Vedere wiki nightwatch tags page e guardare questo esempio:

// --- file1.js --- 
module.exports = { 
    tags: ['login'], 
    'Test 1':function(){ 
     //TODO test 1 
    } 
}; 

// --- file2.js --- 
module.exports = { 
    tags: ['special', 'createUser'], 
    'Test 2':function(){ 
     //TODO test 2 
    }, 
}; 

// --- file3.js --- 
module.exports = { 
    tags: ['logoff', 'special'], 
    'Test 3':function(){ 
     //TODO test 3 
    }, 
} 

Se si esegue:

nightwatch.js --tag login 

eseguito solo Test 1, se si esegue:

nightwatch.js --tag special 

Test 2 e Test 3 verrà eseguito.

Puoi specifica più di un tag

nightwatch.js --tag tag1 --tag tag2 

separata funzione di ogni test è obbligatoria in quanto Nightwatch maneggiato con filematcher ogni file. See Github code.

PD: Se il file contiene errori di sintassi, è possibile che prova non correre o il test non è stato trovato

+1

Questo è davvero fantastico - Penso che sarebbe ottimale se funzionasse come moka e grepping. Questo è quello che speravo! –

+0

Sì, ma non funziona in questo modo. Se ti piace, controlla [filematcher.js util lib] (https://github.com/beatfactor/nightwatch/blob/6e49ffdb9afa7644c4ecf9dc6bc84fc5bd2f00df/lib/runner/filematcher.js) da github nightwatch repo – albertoiNET

0

si può fare somthing come:

node nightwatch.js -e chrome --test tests/login_test --testcase tc_001 
0

Un altro possibile modo di fare così, sarebbe quella di utilizzare il seguendo su ogni caso di test che si desidera omettere:

'@disabled': true, 

Questo può essere semplicemente impostato su falso o rimosso se si desidera testarlo.