日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

SpringBoot中关于RunWith以及SpringBootTest

發布時間:2024/3/13 javascript 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 SpringBoot中关于RunWith以及SpringBootTest 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

SpringBoot單元測試

@RunWith

在JUnit中有很多個Runner,他們負責調用你的測試代碼,每一個Runner都有各自的特殊功能,你要根據需要選擇不同的Runner來運行你的測試代碼。
如果我們只是簡單的做普通Java測試,不涉及Spring Web項目,你可以省略@RunWith注解,這樣系統會自動使用默認Runner來運行你的代碼。

–@RunWith就是一個運行器

–@RunWith(JUnit4.class)就是指用JUnit4來運行

–@RunWith(SpringJUnit4ClassRunner.class),讓測試運行于Spring測試環 境,以便在測試開始的時候自動創建Spring的應用上下文

–@RunWith(Suite.class)的話就是一套測試集合

@SpringBootTest

依賴

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId></dependency>

Spring Boot @SpringApplicationConfiguration 不能導入的問題,較新版的Spring Boot取消了@SpringApplicationConfiguration這個注解,用@SpringBootTest就可以了

對spring-boot項目進行單元測試是件容易的事兒,需要添加spring-boot-starter-test依賴,然后 使用@RunWith和@SpringBootTest

參考鏈接:
https://blog.csdn.net/yyjava/article/details/81301785?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.control&dist_request_id=35525a6f-e6e7-4e8b-8c42-c036b66f7dad&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.control

https://www.cnblogs.com/qingmuchuanqi48/p/11886618.html

https://blog.csdn.net/weixin_39220472/article/details/87714756?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.control&dist_request_id=cdebb9df-7069-476a-907e-a6379a6a0cd1&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.control

總結

以上是生活随笔為你收集整理的SpringBoot中关于RunWith以及SpringBootTest的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。