Skip to content

FirstSteps

Jochen Wierum edited this page Feb 19, 2014 · 12 revisions

FirstSteps

This document describes how to use FitGoodies.

Using FitGoodies with Maven

FitGoodies is available in mavens central repository. There is no need to setup maven in any special way and you can safely skip this section. However, if you want to, you can can install FitGoodies from source.

Creating a project

To create a project that uses fitgoodies, simply copy/type:

mvn archetype:create -DarchetypeVersion=1.2.4 \
-DarchetypeArtifactId=archetype-fitgoodies-quickstart \
-DarchetypeGroupId=de.cologneintelligence \
-DgroupId=org.example -DartifactId=myProject -Dversion=1.0

or use the newer way:

mvn archetype:generate -B -DarchetypeCatalog=local \
  -DarchetypeVersion=1.2.4 \
  -DarchetypeArtifactId=archetype-fitgoodies-quickstart \
  -DarchetypeGroupId=de.cologneintelligence \
  -DgroupId=org.example -DartifactId=myProject -Dversion=1.0

and replace "org.example" and "myProject" with more specific values.

Using FitGoodies in an existing project

To use FitGoodies an an existing project, add the following lines to your pom.xml:

<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">
  ...
  <dependencies>
    <dependency>
      <groupId>de.cologneintelligence</groupId>
      <artifactId>fitgoodies</artifactId>
      <version>1.2.3</version>
    </dependency>
    ...
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <!-- dependencies is optional, use whatever you need -->
        <dependencies>
          <dependency>
            <groupId>org.apache.derby</groupId>
            <artifactId>derby</artifactId>
            <version>10.1.3.1</version>
          </dependency>
          <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.14</version>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <id>default</id>
            <phase>integration-test</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <inherited>true</inherited>
            <configuration>
              <tasks>
                <property name="tests" value="${basedir}/src/test/fixtures" />
                <property name="target" value="${project.build.directory}/test/fixtures" />
                <property name="reltarget" value="test/fixtures" />
                
                <copy todir="${target}">
                  <fileset dir="${tests}" erroronmissingdir="false"
                           casesensitive="false" excludes="**/*.html" />
                </copy>
                
                <java classname="de.cologneintelligence.fitgoodies.runners.DirectoryRunner" 
                      dir="${project.build.directory}"
                      fork="true" failonerror="true">
                  <classpath>
                    <path refid="maven.test.classpath" />
                  </classpath>
                  <arg value="${tests}" />
                  <arg value="${reltarget}" />
                  <arg value="utf-8" />
                </java>
              </tasks>
            </configuration>
          </execution>
        </executions>
      </plugin>
      ...
    </plugins>
  </build>
</project>

Running the tests

To execute the tests, run

mvn integration-test

Using FitGoodies without Maven

Installing FitGoodies

This document assumes, that you already have fitgoodies.jar. If you do not have it, you can download it from GitHub or build it from source.

Running tests

To use FitGoodies, you need fit.jar and fitgoodies.jar in your CLASSPATH. Fit can be downloaded at http://fit.c2.com.

There are several ways to run Fixtures. If you have the libs in lib/ and want to generate reports from all HTML files in fit-testsuite/, run this command:

$ mkdir reports
$ java -classpath lib/fit.jar:lib/fitgoodies.jar de.cologneintelligence.fitgoodies.runners.AutoRunner fit-testsuite/ reports/

If you rather would like to analyze only one file, you can specify that too:

$ mkdir reports
$ java -classpath lib/fit.jar:lib/fitgoodies.jar de.cologneintelligence.fitgoodies.runners.AutoRunner fit-testsuite/simpletests.html reports/simpletests.html

Optionally, you can specify the encoding as an optional third parameter:

$ mkdir reports
$ java -classpath lib/fit.jar:lib/fitgoodies.jar de.cologneintelligence.fitgoodies.runners.AutoRunner fit-testsuite/ reports/ utf-16

The rest of this document describes how to write small test cases.

Fit basics

If you never worked with fit before, we recommend to read the original documentations, which can be found at http://fit.c2.com. The following pages are interesting for you:

The examples are written in C#, but it should be comprehensible.

Although the examples are made for fit, everything will work in FitGoodies too. Just change the names from fit.ColumnFixture to de.cologneintelligence.ColumnFixture or fitgoodies.ColumnFixture and so on.

The new features

Note: These texts are rather short and not complete. If a feature sounds interesting, read at least the java docs or better: the source. If the source is not clean enough, open a ticket.