jQuery QUnit in .NET
Runs QUnit tests inside .NET by using WatiN.
Based on Joshua Flanagan's original work, but updated to work with the latest version of WatiN (2.0.5 at the time of writing) and QUnit.
There is also an extension to get the QUnit tests working in NUnit. It is easy to copy this extension and change it to work with your favourite unit testing framework.
Asynchronous test timeouts
When calling the
NQUnit.GetTests() method there is a
maxWaitInMs parameter, that by default is set to -1 (if you don't specify it), this parameter has the following effect:
- If -1 (or any number less than 0), then the test suite will wait forever for any asynchronous QUnit tests that you have to finish. Note: if your tests don't return then your test runner will need to be force quit.
- If 0, then any asynchronous QUnit tests that you have will fail since the test suite will grab the test results of the page as soon as the page finishes loading.
- Any other number will be the maximum time in ms after the page has finished loading that the test suite will wait for any asynchronous tests to complete.
- ReSharper NUnit test runner (unfortunately the separate QUnit tests don't show up as separate NUnit tests on the ReSharper test runner due to limitations of the runner)
- Test-driven.NET NUnit test runner
- NUnit test runner
- TeamCity NUnit test runner (you need to ensure TeamCity can interact with the desktop (if it's run as a service, alternatively you can run TeamCity is run from a .bat file); see this Stack Overflow thread)
You need Internet Explorer so WatiN can fire up an instance to test the QUnit test page(s).
Questions / additions / problems / etc.
- Send me a pull request
- Comment on the blog post linked to in the documentation above
- Email me at: me (at) robdmoore (dot) id (dot) au
- Raise an issue in the issue tracker