Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting QUnit to run tests in order

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?

like image 763
user1028497 Avatar asked Mar 27 '12 06:03

user1028497


1 Answers

First, 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.org/2011/06/curse_you_qunit_1.html. Apparently, adding this to your test suite will help QUnit.config.reorder = false;

like image 140
Steve Hill Avatar answered Nov 12 '22 21:11

Steve Hill