Search code examples
grails-4

How to inject the server port in Grails 4 integration tests?


Since Grails 4 it is not possible anymore to get the server port in grails integration tests this way:

@Value('${local.server.port}')
Integer serverPort

What's the correct way to get the server port in tests?


Solution

  • The serverPort is already injected in Grails 4 integration tests as serverPort. There is no need to create a variable for it.