Skip to content
This repository was archived by the owner on Oct 28, 2021. It is now read-only.

Commit

Permalink
Merge pull request #125 from tomwayson/grunt
Browse files Browse the repository at this point in the history
added grunt and configured to run intern tests via selenium
  • Loading branch information
xsokev committed Jul 6, 2014
2 parents 91e1926 + cd6d853 commit a213b84
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 22 deletions.
30 changes: 30 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*jshint node:true */
module.exports = function (grunt) {
grunt.initConfig({
intern: {
runner: {
options: {
config: 'tests/intern',
runType: 'runner'
}
}
},
'selenium-launch': {
options: {
port: 4444,
jarDir: 'vendor/selenium/',
jar: 'selenium-server-standalone-2.42.2.jar'
}
}
});

// Loading using a local git copy
grunt.loadNpmTasks('intern');
grunt.loadNpmTasks('grunt-se-launch');

// Register a test task
grunt.registerTask('test', ['selenium-launch', 'intern:runner']);

// By default we just test
grunt.registerTask('default', ['test']);
};
93 changes: 90 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,103 @@ To run the intern tests, you will need to first install the Intern by running th

**NOTE**: The Intern looks for Dojo to be installed under the `vendor` (see above).

#### Running the Intern Unit Test Suites
#### Running the Intern Unit Test Suites in a Browser

To run the Intern tests in a browser:
To run the Intern unit test suites in a browser:

1. open your browser *and* the browser's console window
2. load `http://host/path/to/Dojo-bootstrap/node_modules/intern/client.html?config=tests/intern`

You should see something like:
You should see something like:

![screen shot 2014-06-27 at 7 47 55 pm](https://cloud.githubusercontent.com/assets/662944/3419594/b8ed8aa4-fe6e-11e3-9f53-d2e94b378aad.png)

#### Running the Intern Unit Test Suites via Grunt/Selenium

Using the Intern's test runnner against a local Selenium install offers many advantages including:

* running your tests in multiple browsers from the command line
* code coverage reporting
* automate running your tests with Grunt
* running functional test suites

You will need to download [Selenium Server](http://docs.seleniumhq.org/download/) and
[chromedriver](https://code.google.com/p/chromedriver/downloads/list). See this issue for several suggestions on how to accomplish this:

https://github.com/theintern/intern-tutorial/issues/5

Once you've downloaded selenium, the Grunt `selenium-launch` task is confgiured to look for the .jar file under `vendor/selenium`, so either create that folder and copy the file there or create a symbolic link from `vendor/selenium` to the folder in which your selenium .jar file was downloaded. The vendor folder should now look like this:

```
└── vendor
└── dojo
├── dojo
└── util
└── selenium
└──selenium-server-standalone-2.42.2.jar
```

You will also need to make sure the path to the chromedriver is in your system's PATH variable.

Finally, you should double check the intern and Grunt configuration files to make sure that they match your environment. Make sure they reference the same version of Selenium that you installed and add/remove any browsers to match the ones that you have installed.

**intern.js**
```
capabilities: {
'selenium-version': '2.42.2'
},
```
....
```
environments: [
{ browserName: 'firefox' },
{ browserName: 'safari' },
{ browserName: 'chrome' }
],
```

**Gruntfile.js**
```
'selenium-launch': {
options: {
port: 4444,
jarDir: 'vendor/selenium/',
jar: 'selenium-server-standalone-2.42.2.jar'
}
}
```
Once you've got everything configured, the easisest way to run your tests is via Grunt by entering the following at the command line:

```
grunt test
```

You should see something like the following:

![screen shot 2014-06-29 at 7 58 21 am](https://cloud.githubusercontent.com/assets/662944/3423607/8c3f30de-ff9f-11e3-9cc5-8391c90845eb.png)

You can also run the tests without Grunt by starting Selenium and the Intern runner manually at the commaind line with:


```
java -jar vendor/selenium/selenium-server-standalone-2.42.2.jar -p 4444
```

Then in a seperate terminal window:

```
./node_modules/.bin/intern-runner config=tests/intern
```

This can be useful if you only want to run specific suites, for example:

```
./node_modules/.bin/intern-runner config=tests/intern suites=tests/popover
```

See the [Intern documentation](https://github.com/theintern/intern/wiki/Running-Intern) for the complete list of parameters that you can use when running the Intern.

#### Writing Intern Unit Test Suites

If you would like to help convert the remaining DOH unit test suites to the Intern, please note that [we are trying to simultaneously update the test suites so that their test data and conditions match the Bootsrap v3 test suites](https://github.com/xsokev/Dojo-Bootstrap/issues/97). We would appreciate help with this effort.
Expand All @@ -101,6 +187,7 @@ The easiest way to run the DOH test suites is to link to the DOH test runner fro
+ [Bootstrap](http://getbootstrap.com/)
+ [The Intern](http://theintern.io/)
+ [The Intern Wiki](https://github.com/theintern/intern/wiki)
+ [Intern Grunt Example](https://github.com/theintern/intern-examples/tree/master/grunt-example)

## License

Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dojo-bootstrap",
"version": "3.0.1",
"version": "3.0.2",
"main": "main",
"description": "Implementation of Bootstrap using the Dojo Toolkit.",
"repository": "xsokev/Dojo-Bootstrap",
Expand All @@ -19,6 +19,8 @@
"homepage": "https://github.com/xsokev/Dojo-Bootstrap",
"dojoBuild": "bootstrap.profile.js",
"devDependencies": {
"intern": "^2.0.0"
"intern": "^2.0.0",
"grunt": "^0.4.5",
"grunt-se-launch": "^0.1.0"
}
}
30 changes: 13 additions & 17 deletions tests/intern.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,24 @@ define({
// https://saucelabs.com/docs/additional-config#desired-capabilities for Sauce Labs capabilities.
// Note that the `build` capability will be filled in with the current commit ID from the Travis CI environment
// automatically
capabilities: {
'selenium-version': '2.39.0'
},
capabilities: {
'selenium-version': '2.42.2'
},

// Browsers to run integration testing against. Note that version numbers must be strings if used with Sauce
// OnDemand. Options that will be permutated are browserName, version, platform, and platformVersion; any other
// capabilities options specified for an environment will be copied as-is
environments: [
{ browserName: 'internet explorer', version: '11', platform: 'Windows 8.1' },
{ browserName: 'internet explorer', version: '10', platform: 'Windows 8' },
{ browserName: 'internet explorer', version: '9', platform: 'Windows 7' },
{ browserName: 'firefox', version: '27', platform: [ 'OS X 10.6', 'Windows 7', 'Linux' ] },
{ browserName: 'chrome', version: '32', platform: [ 'OS X 10.6', 'Windows 7', 'Linux' ] },
{ browserName: 'safari', version: '6', platform: 'OS X 10.8' },
{ browserName: 'safari', version: '7', platform: 'OS X 10.9' }
],
// Browsers to run integration testing against. Note that version numbers must be strings if used with Sauce
// OnDemand. Options that will be permutated are browserName, version, platform, and platformVersion; any other
// capabilities options specified for an environment will be copied as-is
environments: [
{ browserName: 'firefox' },
{ browserName: 'safari' },
{ browserName: 'chrome' }
],

// Maximum number of simultaneous integration tests that should be executed on the remote WebDriver service
maxConcurrency: 3,

// Whether or not to start Sauce Connect before running tests
useSauceConnect: true,
useSauceConnect: false,

// Connection information for the remote WebDriver service. If using Sauce Labs, keep your username and password
// in the SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables unless you are sure you will NEVER be
Expand Down Expand Up @@ -71,5 +67,5 @@ define({
functionalSuites: [ /* 'myPackage/tests/functional' */ ],

// A regular expression matching URLs to files that should not be included in code coverage analysis
excludeInstrumentation: /^tests\//
excludeInstrumentation: /^(?:tests|node_modules|vendor)\//
});
6 changes: 6 additions & 0 deletions tests/unit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// run all unit test suites
require([
'tests/tab',
'tests/collapse',
'tests/popover'
], {});

0 comments on commit a213b84

Please sign in to comment.