亚洲好骚综合-亚洲黄色录像-亚洲黄色网址-亚洲黄色网址大全-99久久99久久-99久久99久久精品国产

您的位置:軟件測試 > 開源軟件測試 > 開源單元測試工具 > junit
Junit參數(shù)化測試Spring應(yīng)用Dubbo接口
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時(shí)間:[ 2017/3/9 13:43:18 ] 推薦標(biāo)簽:單元測試 軟件測試工具

  一、創(chuàng)建基礎(chǔ)類。
package com.tree.autotest;
import org.junit.Before;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestContextManager;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
/**
* 規(guī)則包:
* 規(guī)則編碼:
* 規(guī)則名稱:
* 規(guī)則條件:
* <p>
* Created by zhf2015 on 16/8/1.
*/
//@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:/spring-context.xml"})
@Configuration
public class BaseJunit4Test extends AbstractJUnit4SpringContextTests {
protected TestContextManager testContextManager;
@Before
public void setUpContext() throws Exception {
this.testContextManager = new TestContextManager(getClass());
this.testContextManager.prepareTestInstance(this);
}
}
  二、創(chuàng)建測試類,繼承基礎(chǔ)類。
package com.tree.autotest.testcase.BillDetailTypeService;
import com.datatrees.basisdata.bankbill.model.Bill;
import com.datatrees.basisdata.bankbill.service.BillService;
import com.tree.autotest.BaseJunit4Test;
import com.tree.autotest.commons.CommonUtil_2;
import com.tree.autotest.commons.TestCase;
import com.tree.autotest.jdbc.DBIdConstant;
import com.tree.autotest.jdbc.ManagedSqlUtil;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* Created by lyh on 17/2/13.
*/
@RunWith(value=Parameterized.class)
public class TestSelectListByUserId2 extends BaseJunit4Test{
//    ApplicationContext factory=new ClassPathXmlApplicationContext("classpath:/spring-context.xml");
@Autowired
private BillService billService;
//    private BillService billService = (BillService)factory.getBean("billService");
private static final Logger logger = LoggerFactory.getLogger(TestSelectListByUserId2.class);
private boolean handleOk;
private String insertSql1;
private static String excel;
private static Map allCases;
private Integer testUser;
@Parameterized.Parameters
public static Collection<Integer[]> getTestParameters(){
List<Integer[]> list = new ArrayList<Integer[]>();
list.add(new Integer[]{2000998248});  //expected,valueOne,valueTwo
list.add(new Integer[]{2000020021});
list.add(new Integer[]{2001999335});
String st=list.toString();
System.out.println("list值:" + st);
return list;
}
public TestSelectListByUserId2(Integer userid){
this.testUser = userid;
}
@Before
public void setUp() throws SQLException {
//獲取excel用例列表
excel = "src/main/resources/case/BillService/TestSelectListByUserId.xlsx";
allCases = CommonUtil_2.getAllCases(excel);
System.out.println("setUp 執(zhí)行");
//        //獲取用戶ID
TestCase testcase = CommonUtil_2.getTestCaseBean(allCases, "case1", "case1-1");
testUser =Integer.valueOf(testcase.param1);
//獲取SQL
insertSql1 = testcase.stepSql;
//刪除,添加數(shù)據(jù)
handleOk &= deleteData(testUser);
handleOk &= ManagedSqlUtil.insertBySql(insertSql1, DBIdConstant.MySql_Basisdata_ID);
}
@Test
public void test_case_1() throws Exception {
//++++++++++++++實(shí)際值+++++++++++++
List<Bill> actual_list =
billService.selectListByUserId(testUser);
System.out.println("testUser值:"+testUser);
//++++++++++++++驗(yàn)證+++++++++++++
Assert.assertNotNull("測試失敗",actual_list);
for(int i=0;i<actual_list.size();i++) {
Assert.assertEquals("測試失敗",actual_list.get(i).getUserId(),testUser);
}
System.out.println("actual_list的size:"+actual_list.size());
}
@After
public void tearDown() {
deleteData(testUser);
System.out.println("tearDown 執(zhí)行");
}
//定義數(shù)據(jù)清理
public boolean deleteData(Integer userId) {
String deleteSql1 = "delete from t_bill where UserId="+userId+";";
handleOk &= ManagedSqlUtil.deleteBySql(deleteSql1, DBIdConstant.MySql_Basisdata_ID);
return handleOk;
}
}

軟件測試工具 | 聯(lián)系我們 | 投訴建議 | 誠聘英才 | 申請(qǐng)使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd
主站蜘蛛池模板: 欧美三级黄视频 | 久久免费高清视频 | 一级录像免费录像 | 中国国产一级毛片视频 | 欧美日韩一区二区三区韩大 | 特黄特黄一级高清免费大片 | 国产日韩一区二区 | 甜性涩爱免费看 | 成人做视频免费 | 三级在线网站 | 日本韩国在线播放 | 欧美一区二区三区成人看不卡 | 日本黄色片三级 | 欧美一区=区三区 | 日韩伦理在线播放 | www操操操 | 久久这里只有精品免费看青草 | 欧美成人香蕉网在线观看 | 任你躁在线精品免费视频网站 | 精品日韩欧美 | 欧美视频第一区 | 国产小视频在线 | 最近的2019中文字幕免费一页 | 国产精品亚洲午夜不卡 | 国产成人精品一区二区免费 | 成人精品网 | 国产一极毛片 | 一级成人毛片免费观看 | 97狠狠操| 欧美日韩一二区 | 黄色三级视频网站 | 波多野吉衣在线多野结衣 | 午夜三级影院 | 狠狠色综合色综合网站嗯 | 曰本三级香港三级三级人 | 亚洲性人人天天夜夜摸 | 色视频免费在线观看 | 亚洲动漫精品 | 午夜激情一区 | 天天摸日日舔 | 羞羞视频免费网站欧美 |