Spring Boot Test if web server starts on a specific port
Below is a Spring Boot Test example to test whether the web server started on port 8181. P.S. Tested with Spring Boot 3 and JUnit 5. application.properties server.port = 8181 WebServerTests.java package com.mkyong; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.server.LocalServerPort; import static org.junit.jupiter.api.Assertions.assertEquals; @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class WebServerTests { @LocalServerPort private int port; @Test public …