CD part XVII: Integrate FitNesse into our project

  • 03/03/2017
  • 8 minuten leestijd

CD part XVII: Integrate FitNesse into our project

After configuration to release our artifact in nexus, we need to add integration-test to test the functionality of the software

fitnesse integration with jenkins

source:http://blog.xebia.com/fitnesse-and-dependency-management-with-maven/

  1. we need te create a new folder in our project named fitnesse
  2. navigate to C:\projects\easywebservices\AccountStatusWebservice
  3. create this folder
  4. create a new pom.xml and add this content
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

        <modelVersion>4.0.0</modelVersion>
        <groupId>nl.com.devnl</groupId>
        <artifactId>AccountStatusFitnesse</artifactId>
        <packaging>jar</packaging>
        <version>1.0-SNAPSHOT</version>
        <name>Account Status Fitnesse</name>

        <distributionManagement>  
            <!-- Publish the versioned releases here -->  
            <repository>  
                <id>NexusRepoManager</id>  
                <name>Continuous Delivery Blog Nexus Releases</name>  
                <url>https://localhost:8081/nexus/content/repositories/releases</url>  
            </repository>
            <!-- Publish the versioned snapshots here -->  
            <snapshotRepository>  
                <id>NexusRepoManager</id>  
                <name>Continuous Delivery Blog Nexus Snapshots</name>  
                <url>http://localhost:8081/nexus/content/repositories/snapshots</url>  
            </snapshotRepository>  
        </distributionManagement>

        <repositories>
            <repository>
                <id>NexusRepoManager</id>
                <name>Continuous Delivery Blog Nexus</name>
                <url>http://localhost:8081/nexus/content/groups/public/</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </repository>
        </repositories>
    </project>
  1. next we needed to add the fitnesse dependencies
    <dependencies>        
        <dependency>
            <groupId>org.fitnesse</groupId>
            <artifactId>fitnesse</artifactId>
            <version>20151230</version>
            <scope>runtime</scope>
        </dependency>
    </dependencies>
  1. next we are adding the fitnesse profile
    <profiles>
      <profile>
        <id>fitnesse</id>
        <build>
          <plugins>
            <plugin>
              <artifactId>maven-antrun-plugin</artifactId>
              <version>1.6</version>
              <executions>
                <execution>
                  <id>start-fitnesse</id>
                  <phase>test</phase>
                  <configuration>
                    <tasks>
                      <echo taskname="fitnesse" message="Starting FitNesse..." />
                      <java classname="fitnesseMain.FitNesseMain" classpathref="maven.runtime.classpath" fork="true">
                        <arg line="-p 8000" />
                        <arg line="-d ." />
                      </java>
                    </tasks>
                  </configuration>
                  <goals>
                    <goal>run</goal>
                  </goals>
                </execution>
              </executions>
            </plugin>
          </plugins>
        </build>
        <dependencies>
          <dependency>
            <groupId>org.fitnesse.plugins</groupId>
            <artifactId>maven-classpath-plugin</artifactId>
            <version>1.9</version>
            <scope>runtime</scope>
          </dependency>
        </dependencies>
      </profile>
    </profiles>
  1. test if fitnesse runs by executing mvn -Pfitnesse test
  2. start fitnesse in the browser by entering http://localhost:8000/
  3. yeah, fitnesse runs
  4. now we need to add a plugins.properties file in the root of the fitnesse folders
  5. add SymbolTypes = fitnesse.wikitext.widgets.MavenClasspathSymbolType
  6. and add Theme=bootstrap
  7. add junit dependency
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
  1. create a test-class FitnesseTest
    package nl.com.devnl.fitnesse;

    import org.junit.runner.RunWith;
    import fitnesse.junit.FitNesseRunner;

    @RunWith(FitNesseRunner.class)
    @FitNesseRunner.Suite("FitNesse.UserGuide.TwoMinuteExample")
    @FitNesseRunner.FitnesseDir("../fitnesse")
    @FitNesseRunner.OutputDir("target/fitnesse-results")
    public class FitnesseTest {

    }
  1. when we do a mvn -Pfitnesse test we get an error: FitNesse.UserGuide.TwoMinuteExample(nl.com.devnl.fitnesse.FitnesseTest): [25.0] expected [33]
  2. so we need to fix this!
  3. navigate to C:\projects\easywebservices\AccountStatusWebservice\fitnesse\FitNesseRoot\FitNesse\UserGuide\TwoMinuteExample
  4. open the content.txt file and change 33 into 25.0

add integration test to run in jenkins

  1. add profile
    <profile>
        <id>fitnesse-integration</id>
        <activation>
          <activeByDefault>true</activeByDefault>
        </activation>
        <build>
          <plugins>
              <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.19.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <test>FitnesseTest</test>
                    <disableXmlReport>true</disableXmlReport>
                    <systemPropertyVariables>
                        <TEST_SYSTEM>slim</TEST_SYSTEM>
                        <SLIM_PORT>0</SLIM_PORT>
                    </systemPropertyVariables>
                </configuration>
              </plugin>
          </plugins>
        </build>
        <dependencies>
          <dependency>
            <groupId>org.fitnesse.plugins</groupId>
            <artifactId>maven-classpath-plugin</artifactId>
            <version>1.9</version>
            <scope>runtime</scope>
          </dependency>
        </dependencies>
    </profile>
  1. add properties
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
  1. run mvn clean test-compile failsafe:integration-test -Pfitnesse-integration
  2. the result of the integration test can be found in target/fitnesse-results fitnesse results
  3. so we are done for now

ignore fitnesse

  1. add a file .gitignore
  2. set content
    **/*.zip
    FitNesseRoot/files/*.*
    FitNesseRoot/RecentChanges/*.*