简体   繁体   English

使用WebStorms IDE是否可以从单元测试套件中仅运行一个单元测试?

[英]Using WebStorms IDE is it possible to run only one unit test from a unit test suite?

When using WebStorms as a test runner every unit test is run. 使用WebStorms作为测试运行程序时,将运行每个单元测试。 Is there a way to specify running only one test? 有没有办法指定只运行一个测试? Even only running one test file would be better than the current solution of running all of them at once. 即使只运行一个测试文件也会比同时运行所有这些文件的当前解决方案更好。 Is there a way to do this? 有没有办法做到这一点?

I'm using Mocha. 我正在使用摩卡。

目前不可能,请投票给WEB-10067

You can double up the i on it of d on describe and the runner will run only that test/suite. 您可以将描述中的i加倍,并且跑步者将仅运行该测试/套件。 If you prefix it with x it will exclude it. 如果用x作为前缀,它将排除它。

There is a plugin called ddescribe that gives you a gui for this. 有一个名为ddescribe的插件可以为你提供一个gui。

You can use the --grep <pattern> command-line option in the Extra Mocha options box on the Mocha "Run/Debug Configurations" screen. 您可以在Mocha“运行/调试配置”屏幕的Extra Mocha选项框中使用--grep <pattern>命令行选项。 For example, my Extra Mocha options line says: 例如,我的Extra Mocha选项系列说:

--timeout 5000 --grep findRow

All of your test *.js files, and the files they require , still get loaded, but the only tests that get run are the ones that match that pattern. 所有测试的* .js文件,以及他们的文件require ,仍然可以装,但得到的运行只测试匹配这个模式的人。 So if the parts you don't want to execute are tests, this helps you a lot. 因此,如果您不想执行的部分是测试,这对您有很大帮助。 If the slow parts of your process automatically get executed when your other modules get loaded with require , this won't solve that problem. 如果当其他模块加载了require ,进程的缓慢部分会自动执行,这将无法解决该问题。 You also need to go into the configuration options to change the every time you want to run tests matching a different pattern, but this is quick enough that it definitely saves me time vs. letting all my passing tests run every time I want to debug one failing test. 你还需要进入配置选项,以便每次想要运行匹配不同模式的测试时更改,但这足够快,它肯定会节省我的时间,而不是每次我想调试一次时都要运行所有通过的测试测试失败。

You can run the tests within a scope when you have a Mocha config setting by using .only either on the describe or on the it clauses 通过在describe或it子句中使用.only,可以在具有Mocha配置设置的范围内运行测试

I had some problems getting it to work all the time, but when it went crazy and kept running all my tests and ignoring the .only or .skip I added to the extra mocha options the path to one of the files containing unit tests just like in the example for node setup and suddenly the .only feature started to work again regardless of the file the tests were situated in. 我有一些问题让它一直工作,但当它疯了并继续运行我的所有测试并忽略.only或.skip我添加到额外的mocha选项,其中一个包含单元测试的文件的路径就像在节点设置的示例中,突然,无论测试所在的文件是什么,.only功能都会再次开始工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM