简体   繁体   中英

qUnit: Run subset of tests?

When running qUnit tests in the browser you can run a specific test by clicking on the "Rerun" button.

This will result in a hash identifier for that test to be added as a value to the testId url param and only that test will be run. The only API function is another way of accomplishing this.

But, often times I want to run a couple tests , say, tests 5 through 8.

Is there a way to run a sub-set of tests on a page...or at least a way of referencing these tests with an index, rather than a hash?

There are several options how you could group several tests.

  1. Use Filter .

On the right top of the page there is a Filter , so if several tests have word "myTest" in their test name, you could apply this word to the filter, press go and only tests which have this word in the test name will be run.

在此处输入图片说明

  1. Use Module Filter .

If you add the following code, then you will get additional module of tests which means that all the tests which are after this module definition until another module definition or end of file will be run.

QUnit.module("Test with datetime", {});

Inside the object {} you could also write your setup and teardown methods.

More information for Qunit moduling you could find here .

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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