成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

springboot中怎么實現(xiàn)單元測試

這篇文章給大家介紹springboot中怎么實現(xiàn)單元測試,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。

成都創(chuàng)新互聯(lián)主營義縣網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,成都app開發(fā),義縣h5重慶小程序開發(fā)公司搭建,義縣網(wǎng)站營銷推廣歡迎義縣等地區(qū)企業(yè)咨詢

1. 在類上使用注解:

@RunWith(SpringRunner.class)

@SpringBootTest

@RunWith(SpringRunner.class)@SpringBootTestpublic class RobotsApplicationTests {  @Autowired  DataSource dataSource;  @Test  public void test(){    System.out.println(dataSource.getClass());  }}

2. 繼承CommandLineRunner接口

CommandLineRunner:表示在項目啟動完成后 會執(zhí)行該功能,只需將測試的內(nèi)容寫在其run()方法中,如:

@SpringBootApplication@EnableScheduling@ComponentScan(basePackages={"com.cmit.hall.plat","com.cmit.hall.pub"}) @ServletComponentScan(value= {"com.cmit.hall.pub.interceptor","com.cmit.hall.plat.config","com.cmit.hall.pub.session"})@EnableredisHttpSession(maxInactiveIntervalInSeconds=1800)public class PlatApp implements CommandLineRunner {    @Autowired  DataSource dataSource;  public static void main(String[] args) {    SpringApplication.run(PlatApp.class, args);  }    @Override  public void run(String... args) throws Exception {    System.out.println(">>>>>>>>>>>>>>>服務(wù)啟動執(zhí)行,執(zhí)行加載數(shù)據(jù)等操作<<<<<<<<<<<<<");    System.out.println("DATASOURCE = " + dataSource);  }}

關(guān)于springboot中怎么實現(xiàn)單元測試就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。

當(dāng)前標(biāo)題:springboot中怎么實現(xiàn)單元測試
文章路徑:http://jinyejixie.com/article24/ghhsce.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版、標(biāo)簽優(yōu)化、小程序開發(fā)、網(wǎng)頁設(shè)計公司電子商務(wù)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站制作
大宁县| 锦州市| 内江市| 滕州市| 六枝特区| 阳曲县| 崇信县| 偏关县| 丰原市| 兴隆县| 马公市| 江达县| 永新县| 尼玛县| 武义县| 昭苏县| 高密市| 岑巩县| 阳谷县| 永登县| 金坛市| 岳阳市| 年辖:市辖区| 博乐市| 时尚| 鄂托克旗| 涟源市| 新邵县| 卢氏县| 会昌县| 澄迈县| 迭部县| 英吉沙县| 三江| 洪洞县| 山阳县| 长葛市| 丽水市| 丰宁| 双峰县| 达尔|