我会自己回答这个问题。
在花费了额外的时间后,事实证明
TestRestTemplate已经知道并设置了正确的端口。RestAssured没有…
这样我就可以进行下面的测试了,没有任何问题。
@RunWith(SpringRunner.class)@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)public class SizesRestControllerIT { @LocalServerPort int port; @Before public void setUp() { RestAssured.port = port; } @Test public void test2() throws InterruptedException { given().basePath("/clothes").get("").then().statusCode(200); }}我本可以发誓以前尝试过这种方式…但是我想我确实为此使用了其他一些注释…



