index.md 1.96 KB
Newer Older
Shane A. Stillwell's avatar
Shane A. Stillwell committed
1 2 3 4 5 6
---
title: "Using Testacular with Jenkins for AngularJS e2e Testing"
id: 598
date: "2013-01-09T17:19:46-05:00"
tags: 
- Programming
7 8
- AngularJS
- Jenkins
Shane A. Stillwell's avatar
Shane A. Stillwell committed
9 10 11 12 13 14
---

# Rollcall!

* AngularJS in your code ✓
* Jenkins ✓
15
* [Node.js is installed]({{< ref "/post/installing-node-js-on-centos-using-nave/index.md" >}}) on the Jenkins server? ✓
Shane A. Stillwell's avatar
Shane A. Stillwell committed
16 17 18 19 20 21 22
* Testacular is installed on the Jenkins server ✓*   PhantomJS is installed on the Jenkins server &#10003;

If that's what you're using, this is how I set up testing on the Jenkins server.

1. Create a new job in Jenkins
2. Pull from Git (or whatever), Trigger how you want too. That's not germane to this article.
3. Inject some environment variables (may need to install a plugin for this)
23
   ![Env Vars](images/Screen-Shot-2013-01-09-at-10.35.05-AM.png)
Shane A. Stillwell's avatar
Shane A. Stillwell committed
24
4. Start a web server on the Jenkins server for Testacular to use and call the target in the `build.xml` script (see below)
25
   ![Web Server](images/Screen-Shot-2013-01-09-at-10.44.58-AM.png)
Shane A. Stillwell's avatar
Shane A. Stillwell committed
26
5. Generate the report (test_out/e2e.xml is configured in testacular-e2e.conf.js)
27
    ![xunit](images/Screen-Shot-2013-01-09-at-11.12.27-AM.png)
Shane A. Stillwell's avatar
Shane A. Stillwell committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71

## build.xml

```xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="My Project" default="build" basedir=".">
    <target name="testacular-e2e" description="Testacular AngularJS e2e Tests">
        <echo message="Running the tests ..." />
        <exec executable="testacular" output="test_out/output.txt" failonerror="true">
            <arg value="start" />
            <arg value="./config/testacular-e2e.conf.js" />
        </exec>
        <echo message="Tests done" />
    </target>
</project>
```

## config/testacular-e2e.conf.js

```javascript
basePath = '../';

files = [
  ANGULAR_SCENARIO,
  ANGULAR_SCENARIO_ADAPTER,
  'test/e2e/**/*.js'
];

autoWatch = false;

browsers = ['PhantomJS'];

reporters = ['dots', 'junit'];
singleRun = true;

proxies = {
  '/': 'http://localhost:8000/'
};

junitReporter = {
  outputFile: 'test_out/e2e.xml',
  suite: 'e2e'
};
```