我维护了一个相当大的 micronaut 应用程序,进行了数千次测试。最近我迁移到 Azure 并开始看到这些带有此错误的不稳定测试
Test initializationError FAILED
io.micronaut.http.server.exceptions.ServerStartupException: Unable to start Micronaut server on port: 43218
应用程序-test.yml
---
micronaut:
server:
port: ${random.port}
示例测试
@MicronautTest
class MathServiceSpec extends Specification {
@Inject
MathService mathService
@Unroll
void "should compute #num times 4"() {
when:
def result = mathService.compute(num)
then:
result == expected
where:
num | expected
2 | 8
3 | 12
}
我看不出 micronaut 选择用于 random.port 的端口的任何明显原因,或者为什么这只是在迁移到 Azure 后才开始发生,因为我无法建立明显的连接。