1 | #gulp-nunit-runner
|
2 |
|
3 |
|
4 | A [Gulp.js](http://gulpjs.com/) plugin to facilitate running [NUnit](http://www.nunit.org/) tests on .NET assemblies. Much of this work was inspired by the [gulp-nunit](https://github.com/stormid/gulp-nunit) plugin.
|
5 |
|
6 | ##Installation
|
7 | From the root of your project (where your `gulpfile.js` is), issue the following command:
|
8 |
|
9 | ```bat
|
10 | npm install --save-dev gulp-nunit-runner
|
11 | ```
|
12 |
|
13 | ##Usage
|
14 | The plugin uses standard `gulp.src` globs to retrieve a list of assemblies that should be tested with Nunit. In its simplest form you just need to supply the command with the path to your `nunit-console.exe`. You should add `{read: false}` to your `gulp.src` so that it doesn't actually read the files and only grabs the file names.
|
15 |
|
16 | ```javascript
|
17 | var gulp = require('gulp'),
|
18 | nunit = require('gulp-nunit-runner');
|
19 |
|
20 | gulp.task('unit-test', function () {
|
21 | return gulp.src(['**/*.Test.dll'], {read: false})
|
22 | .pipe(nunit({
|
23 | executable: 'C:/nunit/bin/nunit-console.exe',
|
24 | }));
|
25 | });
|
26 |
|
27 | ```
|
28 | This would result in the following command being executed (assuming you had Database and Services Test assemblies.)
|
29 |
|
30 | ```bat
|
31 | C:/nunit/bin/nunit-console.exe "C:\full\path\to\Database.Test.dll" "C:\full\path\to\Services.Test.dll"
|
32 | ```
|
33 |
|
34 | Note: If you use Windows paths with `\`'s, you need to escape them with another `\`. (e.g. `C:\\nunit\\bin\\nunit-console.exe`). However, you may also use forward slashes `/` instead which don't have to be escaped.
|
35 |
|
36 | You may also add options that will be used as NUnit command line switches. Any property that is a boolean `true` will simply be added to the command line while String values will be added to the switch parameter separated by a colon.
|
37 |
|
38 | For more information on available switches, see the NUnit documentation:
|
39 |
|
40 | [http://www.nunit.org/index.php?p=consoleCommandLine&r=2.6.3](http://www.nunit.org/index.php?p=consoleCommandLine&r=2.6.3)
|
41 |
|
42 | ```javascript
|
43 | var gulp = require('gulp'),
|
44 | nunit = require('gulp-nunit-runner');
|
45 |
|
46 | gulp.task('unit-test', function () {
|
47 | return gulp.src(['**/*.Test.dll'], {read: false})
|
48 | .pipe(nunit({
|
49 | executable: 'C:/nunit/bin/nunit-console.exe',
|
50 | options: {
|
51 | nologo: true,
|
52 | config: 'Release',
|
53 | transform: 'myTransform.xslt'
|
54 | }
|
55 | }));
|
56 | });
|
57 | ```
|
58 | This would result in the following command:
|
59 |
|
60 | ```bat
|
61 | C:/nunit/bin/nunit-console.exe /nologo /config:"Release" /transform:"myTransform.xslt" "C:\full\path\to\Database.Test.dll" "C:\full\path\to\Services.Test.dll"
|
62 | ```
|
63 |
|
64 |
|
65 |
|