在集成测试阶段执行Maven模块

sai*_*ama 2 java automated-tests maven

我想启动一个兄弟maven 3模块,它在我的一个maven模块中充当应用服务器,以对系统运行集成测试.

我的maven项目看起来与此类似:

  • 父模块
    • 模块A.
    • 模块B.

现在我想在maven的预集成测试阶段启动"模块A",然后运行模块B中包含的所有集成测试.我设法在模块B中运行集成测试,但没有找到"光滑"的方式启动模块B处于预集成测试阶段.

这样做的最佳做法是什么?使用mojo-exec插件?如何配置?使用"脏"shell脚本并为模块A执行mvn run?

编辑

我不想在预集成测试阶段启动应用程序服务器,但想要运行maven模块(它本身启动了mojo-exec-plugin).运行意味着启动打包(工作)模块的主类!

And*_*yuk 5

尝试使用绑定到安装阶段的maven-exec-plugin的java目标:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.2.1</version>
    <executions>
      <execution>
        <id>start-app</id>
        <phase>install</phase>
        <goals>
          <goal>java</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <mainClass>com.example.Main</mainClass>
      <arguments>
        <argument>argument1</argument>
        ...
      </arguments>
      <systemProperties>
        <systemProperty>
          <key>myproperty</key>
          <value>myvalue</value>
        </systemProperty>
        ...
      </systemProperties>
    </configuration>
  </plugin>
Run Code Online (Sandbox Code Playgroud)