0

In order to automate some FitNesse tests in our system I need to essentially do the following:

  1. Build everything in Maven.
  2. Start a server process using the built code.
  3. Run FitNesse tests against the server.

This is all fine, except for starting the server within the Maven integration-test phase. Mainly, I'm not really sure how to get the project classpath into the java task; the FitNesse Java task is working fine, but that doesn't need to access the compiled classes. So far, I have the following Maven config but the first Java execution fails because the class is not found. Presumably I need this task to behave something like the surefire plugin and use a classpath with all compiled projects and dependencies.

<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
    <execution>
    <id>start-fitnesse-integration</id>
    <phase>integration-test</phase>
    <configuration>
        <tasks>
        <echo taskname="fitnesse" message="Starting Server..."/>
        <java classname="com.xyz.ServerProcess" fork="true" failonerror="true">
            <jvmarg value="-Xmx1024m"/>
            <!-- etc. -->
        </java>

        <echo taskname="fitnesse" message="Starting Fitnesse tests..."/>
        <java classname="fitnesseMain.FitNesseMain" classpathref="maven.runtime.classpath" fork="true" failonerror="true">
            <!-- FitNesse command - works OK -->
        </java>
        </tasks>
    </configuration>
    <goals>
        <goal>run</goal>
    </goals>
    </execution>
</executions>
</plugin>

How should the classpath be specified for the first Java task? Ideas for alternate solutions also welcome.

BarrySW19
  • 3,759
  • 12
  • 26
  • I would suggest to take a look at the [maven-dependency-plugin](http://maven.apache.org/plugins/maven-dependency-plugin/build-classpath-mojo.html) which provides a way to get the classpath also for different scopes. Furthermore there exists a [fitness-maven-launcher-plugin](https://code.google.com/p/fitnesse-launcher-maven-plugin/) which might help also. – khmarbaise Apr 24 '15 at 17:19
  • You are asking about the FIRST java task, correct? So you are essentially asking how to start your own server process from a Maven run (using Ant)? – Fried Hoeben Apr 26 '15 at 07:20
  • @Fried Hoeben - yes, that's correct. – BarrySW19 Apr 27 '15 at 09:45

3 Answers3

0

I would recommend either:

  1. Making to independent build scripts (possibly with a third to combine both): one to create deploy and start your server, and another to run your FitNesse test and report on that (the latter is easy to achieve using a surefire run and a unit test with @RunWith(FitNesseRunner.class)).
  2. Having your FitNesse run also start the server (in a SuiteSetup) and stopping it after the test suite (in a TearDown). That way the FitNesse test set is self contained and can be executed independently of your build script (interactively via its wiki for instance).
Fried Hoeben
  • 3,247
  • 16
  • 14
0

The way I eventually got this going was to use the exec-maven-plugin to execute a new JVM with the exec:exec goal (i.e. the executable is 'java'). This allows you to include the <classpath/> tag within the arguments list. This does mean the executed class needed to be responsible for starting the server itself in background and then invoking the FitNesse suite, but at least it all works.

BarrySW19
  • 3,759
  • 12
  • 26
0

I had to deal with that regarding cucumber-jvm under a different Maven folder structure. In order for the tests to be compiled, besides the maven-antrun-plugin configurations, I needed to use build-helper-maven-plugin:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>build-helper-maven-plugin</artifactId>
  <version>3.2.0</version>
  <executions>
    <execution>
      <id>add-integration-test-sources</id>
      <phase>generate-test-sources</phase>
      <goals>
        <goal>add-test-source</goal>
      </goals>
      <configuration>
        <sources>
          <source>src/test-functional/java</source>
        </sources>
      </configuration>
    </execution>
    <execution>
      <id>add-integration-test-resources</id>
      <phase>generate-test-resources</phase>
      <goals>
        <goal>add-test-resource</goal>
      </goals>
      <configuration>
        <resources>
          <resource>
            <filtering>true</filtering>
            <directory>src/test-functional/resources</directory>
          </resource>
        </resources>
      </configuration>
    </execution>
  </executions>
</plugin>
manasouza
  • 1,189
  • 1
  • 14
  • 26