Run ASPUnit unit tests in a headless PhantomJS instance.
This plugin requires Grunt
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-aspunit --save-dev
Run this task with the
grunt aspunit command.
Task targets, files and options may be specified according to the grunt Configuring tasks guide.
Also note that running grunt with the
--debug flag will output a lot of PhantomJS-specific debugging information. This can be very helpful in seeing what actual URIs are being requested and received by PhantomJS.
https:// urls to be passed to PhantomJS. Note that urls must be served by a web server, and since this task doesn't contain a web server, one will need to be configured separately. The grunt-iisexpress plugin provides an IIS web server.
When true, the whole task will not fail when there are individual test failures. This can be set to true when you always want other tasks in the queue to be executed.
In this example,
grunt aspunit will test two files, served from the server running at
// Project configuration.grunt;
It's important to note that grunt does not automatically start a
localhost web server. That being said, the grunt-iisexpress plugin
iisexpress task can be run before the
aspunit task to serve files via an IIS web server.
In the following example, if a web server isn't running at
grunt aspunit with the following configuration will fail because the
aspunit task won't be able to load the specified URLs. However, running
grunt iisexpress aspunit will first start an IIS web server at
localhost:8000 with its base path set to the Gruntfile's directory. Then, the
aspunit task will be run, requesting the specified URLs.
// Project configuration.grunt;// This plugin provides the "iisexpress" task.grunt;// A convenient task alias.grunt;
ASPUnit callback methods and arguments are also emitted through grunt's event system so that you may build custom reporting tools. Please refer to to the ASPUnit documentation for more information.
The events, with arguments, are as follows:
In addition to ASPUnit callback-named events, the following events are emitted by Grunt:
(url): when PhantomJS is spawned for a test
(url): when PhantomJS could not open the given url
aspunit.fail.timeout: when an ASPUnit test times out, usually due to a missing
You may listen for these events like so:
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.