Skip to content

Setting up your environment

wakaleo edited this page Sep 26, 2011 · 4 revisions

This page describes in some detail how to set up your development environment to work with Thucydides. The documentation here assumes you are using Maven. (Note that, at the time of writing, the Thucydides easyb plugin will not work correctly with Maven 3 before version 3.0.4 - if you run into issues, try running the tests using Maven 2.2.1).

Configuring the Maven repositories

The first thing you need to do is to get hold of the Thucydides libraries. The Thucydides libraries are available on the Sonatype OSS repositories, so you will have to add them to your local settings.xml file or (better still) to your Enterprise Repository Manager. The repositories in question are:

and

If you are using Maven, you can add these to your local settings.xml file (in your .m2 directory)

<repositories>
    <repository>
        <id>sonatype-oss-releases</id>
        <name>Sonatype OSS Releases</name>
        <url>https://oss.sonatype.org/content/repositories/releases</url>
    </repository>
    <repository>
        <id>sonatype-oss-snapshots</id>
        <name>Sonatype OSS Snapshots</name>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </repository>
</repositories>

To use Thucydides with easyb, you will also need to add the following Maven repositories to your local settings.xml or to your Enterprise Repository Manager:

If you want to use the latest snapshot releases, you will need to add the following repository as well:

If you are using Maven, you can add these to your local settings.xml file (in your .m2 directory)

<repositories>
    <repository>
        <id>wakaleo-releases</id>
        <name>Wakaleo Releases</name>
        <url>http://maven.wakaleo.com/releases</url>
    </repository>
    <repository>
        <id>wakaleo-snapshots</id>
        <name>Wakaleo Snapshots</name>
        <url>http://maven.wakaleo.com/snapshots</url>
    </repository>
</repositories>      

Configuring the plugin groups

You should also add a new pluginGroup to your local settings.xml file. You need this to be able to generate the Thucydides aggregate reports from the command line:

 <pluginGroups>
     ...
     <pluginGroup>net.thucydides.maven.plugins</pluginGroup>  
</pluginGroups>

Configuring your project

Now we will look at configuring your Maven project. You can either integrate Thucydides tests into an existing project, or create a new dedicated project (or module) for your web tests.

Adding the dependencies

First, add the Thucydides dependencies to your pom.xml file, as shown here:

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>net.thucydides</groupId>
        <artifactId>thucydides-junit</artifactId>
        <version>0.4.9</version>
    </dependency>
    <dependency>
        <groupId>net.thucydides.easyb</groupId>
        <artifactId>thucydides-easyb-plugin</artifactId>
        <version>0.4.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.6.1</version>
        <type>pom</type>
    </dependency> 
	...
</dependencies> 

A common configuration is to use easyb for high-level acceptance tests and JUnit for more low-level tests. If you are not using easyb, you can omit the thucydides-easyb-plugin dependency.

Configuring the plugins

Thucydides runs as part of the conventional JUnit or easyb tests, so there is little configuration to do. If you are integrating Thucydides into an existing project, you should bind the tests being run by Thucydides to the integration-test phase.

JUnit

Thucydides tests will run fine with just the standard JUnit configuration. However, if you want to be able to specify the browser to use during the tests from the command line (very useful for cross-browser testing), you need to get Maven to pass the webdriver.driver property to JUnit. You can do this using the <systemPropertyVariables> configuration element shown below.

<properties>
	...
    <webdriver.driver>firefox</webdriver.driver>
</properties>
         
<plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-surefire-plugin</artifactId>
     <version>2.7.1</version>
     <configuration>
         <systemPropertyVariables>
             <webdriver.driver>${webdriver.driver}</webdriver.driver>
         </systemPropertyVariables>
     </configuration>
 </plugin> 

Now you can run your tests and specify the browser as shown here:

$ mvn test -Dwebriver.driver=iexplorer

Easyb

The easyb configuration is shown below. Note we are currently using a slightly customized version (version 1.2.1) of the plugin - we will resume using a standard easyb distribution in the near future. Note that, as with JUnit, we are using the special <jvmArguments> configuration element to pass in the webdriver.driver property.

<plugin>
   <groupId>org.easyb</groupId>
   <artifactId>maven-easyb-plugin</artifactId>
   <version>1.2.1</version>
   <executions>
       <execution>
           <goals>
               <goal>test</goal>
           </goals>
       </execution>
   </executions>
   <dependencies>
       <dependency>
           <groupId>org.codehaus.groovy</groupId>
           <artifactId>groovy-all</artifactId>
           <version>1.7.10</version>
       </dependency>
   </dependencies>
   <configuration>
       <storyType>html</storyType>
       <storyReport>target/easyb/easyb.html</storyReport>
       <easybTestDirectory>src/test/stories</easybTestDirectory>
	   <jvmArguments>-Dwebdriver.driver=${webdriver.driver}</jvmArguments>
   </configuration>
</plugin>                 

Reporting

The last thing you need to configure is the Thucydides reporting. The Thucydides report plugin generates the aggregate test reports. To use this plugin, just declare it in your `' section:

<plugin>
    <groupId>net.thucydides.maven.plugins</groupId>
    <artifactId>maven-thucydides-plugin</artifactId>
    <version>0.4.9</version>
</plugin>