问题描述
我有一些测试UI的测试,也可以用来创建数据.
I have several tests which test the UI and also serve to create data along the way.
一组单独的测试依赖于此数据,这意味着这些测试必须在第一组测试运行之后才能运行.
A separate set of tests rely on this data, meaning that these must run only after the first set have run.
我知道要运行一组或使用标签运行它们,但是如何按特定顺序运行它们呢?
I know about running a group of them, or running them with tags, but how can I run them in a specific order?
推荐答案
Nightwatch会按顺序运行特定文件中的每个测试,因此一种(简单的)解决方案是将每个测试按您的顺序放入同一个文件中希望他们跑步.
Nightwatch will run each test within a particular file in order, so one (naive) solution would be to put every test in the same file, in the order you want them to run.
如果单个文件的测试过多,这将变得很笨拙.要解决此问题,您可以利用Nightwatch按字母顺序运行每个测试文件.一种方法是在每个测试文件前添加一个数字,该数字指示您希望它们运行的顺序.例如,如果您有两个测试文件before.js
和after.js
,并且您想要before.js
要首先运行,您只需将文件名更改为01before.js
和02after.js
.这将使Nightwatch按所需顺序读取文件.
This will get unwieldy if you have too many tests for a single file. To get around this, you can take advantage of Nightwatch running each test file in alphabetical order. One way to do this would be to prefix each test file with a number indicating the order you want them to be run in. For example, if you had two test files, before.js
and after.js
, and you wanted before.js
to run first, you could just change the names of the files to 01before.js
and 02after.js
. This will make Nightwatch read the files in the order you want.
这篇关于如何按特定顺序运行Nightwatch测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!