Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting external process during integration testing in maven

I want completely automated integration testing for a Maven project. The integration tests require that an external (platform-dependent) program is started before running. Ideally, the external program would be killed after the unit tests are finished, but is not necessary.

Is there a Maven plugin to accomplish this? Other ideas?

like image 259
flicken Avatar asked Jan 24 '23 01:01

flicken


1 Answers

You could use the antrun plugin. Inside you would use ant's exec apply task.

Something like this.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.2</version>
    <executions>
      <execution>
        <phase> <!-- a lifecycle phase --> </phase>
        <configuration>

          <tasks>
            <apply os="unix" executable="cmd">
              <arg value="/c"/>
              <arg value="ant.bat"/>
              <arg value="-p"/>
            </apply>
            <apply os="windows" executable="cmd.exe">
              <arg value="/c"/>
              <arg value="ant.bat"/>
              <arg value="-p"/>
            </apply>
          </tasks>

        </configuration>
        <goals>
          <goal>run</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

Ant support os specific commands of course through the condition task.

like image 65
sblundy Avatar answered Feb 05 '23 20:02

sblundy