How do I create a Qunit test suite that has its own qunit appliances?

I have two XXXTest.html files, each one similar to:

<html> <head> <link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.11.0.css" /> <script src="../../../public/scripts/common/SomeUtils.js"></script> </head> <body> <div id="qunit"></div> <div id="qunit-fixture"> <div id="findme">Something specific for the code under test</div> </div> <script src="http://code.jquery.com/qunit/qunit-1.11.0.js"></script> <script src="SomeUtilsTest.js"></script> </body> </html> 

Each has its own qunit-fixture, so the html file is equivalent to the JUnit Test Class. I understand that qunit treats modules as roughly the same as the test class, but this is very limiting.

What is the best way to have a master html file that will run tests in other html files? Or what is the β€œright way” to separate the tests that need their own fixtures in the qunit world?

+6
source share
2 answers

Usually I have a runner.html wizard, leave my #qunit-fixture empty and fill the fixture from my module installation method.

However, if you want to share html with ease:

  • Store html in a template (e.g. some-test-fixture.html)
  • Download the template using ajax (or requirejs! Text )

Then you can fill out # qunit-fixture if necessary

+4
source

There is a good plugin for this: qunit-composite .

"Composite is a QUnit plugin that, when transferring an array of files, opens each of these files inside an iframe, runs tests, and displays the results as one set of QUnit tests."

+3
source

All Articles