Normally my application ran on port 8080, but in the test it seemed to run on a different port (although I did not change anything regarding the ports).
For me, the following solution to the problem:
Adding this to SpringBootTest:
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
Getting the assigned port (does not work without setting up an arbitrary port):
@LocalServerPort private int port;
Prefix of the test with guaranteed storage with a new port parameter:
given().port(port).when().get...
OR
@Before public void setUp() throws Exception { RestAssured.port = port; }
source share