DBunit 是一種擴(kuò)展于JUnit的數(shù)據(jù)庫驅(qū)動(dòng)測(cè)試框架,它使數(shù)據(jù)庫在測(cè)試過程之間處于一種已知狀態(tài),如果一個(gè)測(cè)試用例對(duì)數(shù)據(jù)庫造成了破壞性影響,它可以幫助避免造成后面的測(cè)試失敗或者給出錯(cuò)誤結(jié)果。

DBunit通過維護(hù)真實(shí)數(shù)據(jù)庫與數(shù)據(jù)集(IDataSet)之間的關(guān)系來發(fā)現(xiàn)與暴露測(cè)試過程中的問題。IDataSet 代表一個(gè)或多個(gè)表的數(shù)據(jù)。此處IDataSet可以自建,可以由數(shù)據(jù)庫導(dǎo)出,并以多種方式體現(xiàn),xml文件、XLS文件和數(shù)據(jù)庫查詢數(shù)據(jù)等。
基于DBUnit 的測(cè)試的主要接口是IDataSet,可以將數(shù)據(jù)庫模式的全部?jī)?nèi)容表示為單個(gè)IDataSet 實(shí)例。這些表本身由Itable 實(shí)例來表示。
1. pom文件配置
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>com.github.springtestdbunit</groupId>
<artifactId>spring-test-dbunit</artifactId>
<version>1.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.dbunit</groupId>
<artifactId>dbunit</artifactId>
<version>2.5.3</version>
</dependency>
當(dāng)前題目:SpringBootDBUnit單元測(cè)試(小結(jié))-創(chuàng)新互聯(lián)
標(biāo)題網(wǎng)址:http://chinadenli.net/article18/dpiigp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供服務(wù)器托管、網(wǎng)站導(dǎo)航、標(biāo)簽優(yōu)化、網(wǎng)站制作、做網(wǎng)站、建站公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容