Ho prova:Come eseguire un singolo test in Nightwatch
module.exports = {
'Test 1':function(){},
'Test 2':function(){}
'Test 3':function(){}
}
Voglio correre Test 3
e non tutti gli altri. Come posso farlo?
Ho prova:Come eseguire un singolo test in Nightwatch
module.exports = {
'Test 1':function(){},
'Test 2':function(){}
'Test 3':function(){}
}
Voglio correre Test 3
e non tutti gli altri. Come posso farlo?
Un nuovo parametro --testcase è stato aggiunto a eseguire un TestCase specificato.
nightwatch.js --test tests\demo.js --testcase "Test 1"
Si tratta di una nuova funzionalità in quanto la v0.6.0
https://github.com/beatfactor/nightwatch/releases/tag/v0.6.0
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
È 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
Questo è davvero fantastico - Penso che sarebbe ottimale se funzionasse come moka e grepping. Questo è quello che speravo! –
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
si può fare somthing come:
node nightwatch.js -e chrome --test tests/login_test --testcase tc_001
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.
Woot! Grazie a @NicoPennec –