admin管理员组文章数量:1277901
I've used qunit to write a series of tests for javascript code I have. Right now for some reason, the first test in my list will run, and then the LAST test in the list runs, followed by the 2nd to last, 3rd to last, 4th to last, etc... It's crucial for my tests that things run in the order that I have them in. I tried turning off that option where qunit runs tests that failed last time first, but it's still doing this. Is there any way to fix this?
I've used qunit to write a series of tests for javascript code I have. Right now for some reason, the first test in my list will run, and then the LAST test in the list runs, followed by the 2nd to last, 3rd to last, 4th to last, etc... It's crucial for my tests that things run in the order that I have them in. I tried turning off that option where qunit runs tests that failed last time first, but it's still doing this. Is there any way to fix this?
Share Improve this question asked Mar 27, 2012 at 6:23 user1028497user1028497 1031 silver badge6 bronze badges2 Answers
Reset to default 11First, figure out why your tests MUST run in a specific order. The whole point of unit testing is that the tests are atomic and it should be possible to run them in any order - if your test suite isn't capable of this, you need to figure out why as it may represent a larger problem.
If you can't figure it out, then you may need to break your test suite up into smaller groups of tests until you find the one(s) causing the issue.
edit: Found this reference at http://www.educatedguesswork/2011/06/curse_you_qunit_1.html. Apparently, adding this to your test suite will help QUnit.config.reorder = false;
Maybe you could consider placing the code that does each major putation in a function that has a test at the beginning that checks if the putation was already done. If the putation is not done, do the putation and save the result somewhere. If the putation has already been done then just return the results. In this way you can have a single putation for all the tests but still be autonomous to the order the tests are done.
I can relate to the problems of time consuming putations in unit testing, but it is imperative to the test group to be able to take any unit test and execute as an independent autonomous test. This is especially true when a critical problem es up and has to be addressed specifically.
本文标签: javascriptGetting QUnit to run tests in orderStack Overflow
版权声明:本文标题:javascript - Getting QUnit to run tests in order - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741254270a2366369.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论