使用restAssured测试Spring Boot Rest应用程序

使用restAssured测试Spring Boot Rest应用程序,第1张

使用restAssured测试Spring Boot Rest应用程序

我会自己回答这个问题。

在花费了额外的时间后,事实证明

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);    }}

我本可以发誓以前尝试过这种方式…但是我想我确实为此使用了其他一些注释



欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5675867.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-16
下一篇2022-12-17

发表评论

登录后才能评论

评论列表(0条)

    保存