本文介紹了在 Maven 集成測試期間啟動外部進程的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我想要對 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.
是否有一個 Maven 插件來完成這個?其他想法?
Is there a Maven plugin to accomplish this? Other ideas?
推薦答案
你可以使用 antrun 插件.在里面你會使用 ant 的 exec 申請任務.
You could use the antrun plugin. Inside you would use ant's exec apply task.
類似的東西.
<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 支持 os 特定命令當然是通過 條件任務.
這篇關于在 Maven 集成測試期間啟動外部進程的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!