我在预集成测试阶段在动态保留端口上启动我的应用程序。我正在使用 GMaven 插件和 Failsafe 发出 REST 调用以确保在继续测试之前成功部署。但是端口号仍然返回为空。我将 portNum 设置为 Maven 环境变量:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<testPort>${portNum}</testPort>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<phase>pre-integration-test</phase>
</execution>
</executions>
</plugin>
但是在 Groovy 脚本中读取端口时,我仍然得到 null:
port = System.getProperty("testPort").toString()
uri = "http://localhost:" + port
log.info(uri)
任何想法表示赞赏。
问候