让QUnit按顺序运行测试 [英] Getting QUnit to run tests in order

查看:81
本文介绍了让QUnit按顺序运行测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用qunit为我的javascript代码编写了一系列测试。现在由于某种原因,我的列表中的第一个测试将运行,然后列表中的最后一个测试运行,然后是第二个到最后一个,第三个到最后一个,第四个到最后一个等等...这对我的测试至关重要事情按照我让他们进入的顺序运行。我尝试关闭该选项,其中qunit运行上次失败的测试,但它仍然这样做。有没有办法解决这个问题?

解决方案

首先,找出你的测试必须按特定顺序运行的原因。单元测试的重点是测试是原子的,应该可以按任何顺序运行它们 - 如果你的测试套件不具备这个功能,你需要找出原因,因为它可能代表一个更大的问题。 / p>

如果您无法弄明白,那么您可能需要将测试套件分成更小的测试组,直到找到导致问题的测试套件为止。



编辑:在 http://www.educatedguesswork.org/2011/06/curse_you_qunit_1.html 。显然,将其添加到您的测试套件将有助于 QUnit.config.reorder = false;


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?

解决方案

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;

这篇关于让QUnit按顺序运行测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆