我正在使用这个maven插件为服务和Kafka创建一个随机端口
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.4.0</version>
<executions>
<execution>
<id>reserve-network-port</id>
<goals>
<goal>reserve-network-port</goal>
</goals>
<phase>process-resources</phase>
<configuration>
<portNames>
<portName>kafka.port</portName>
<portName>service.port</portName>
</portNames>
</configuration>
</execution>
</executions>
</plugin>
字符串
然后我用Surfire运行一些集成测试
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<executions>
<execution>
<id>cucumber-tests</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<systemPropertyVariables>
<log.dir>${project.build.directory}/logs</log.dir>
</systemPropertyVariables>
<includes>
<include>**/*Test.java</include>
<include>**/*Steps.java</include>
<excludes>**/*cucumber.RunCucumberIT.java</excludes>
</includes>
<testFailureIgnore>false</testFailureIgnore>
</configuration>
</execution>
</executions>
</plugin>
型
然后在我的 cucumber 步骤中我试图让它通过
var port = System.getProperty("service.port")
型
但我得到的是null
值
我需要在surefire
插件中设置为在我的 cucumber 执行中可见吗?
1条答案
按热度按时间omqzjyyz1#
看看这个
字符串
更新
您可以尝试在POM文件中执行
maven-surefire-plugin
之前移动build-helper-maven-plugin
的执行!型
祝你好运!