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

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

  一、創(chuàng)建基礎類。
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)建測試類,繼承基礎類。
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 {
//++++++++++++++實際值+++++++++++++
List<Bill> actual_list =
billService.selectListByUserId(testUser);
System.out.println("testUser值:"+testUser);
//++++++++++++++驗證+++++++++++++
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)系我們 | 投訴建議 | 誠聘英才 | 申請使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd
主站蜘蛛池模板: 一级片a级片 | 国产精品天天看天天爽 | 亚洲成人黄色在线观看 | 亚洲最大的视频网站 | 欧美日本不卡 | 黄色一级视频免费看 | 欧美日本国产 | 九九久久国产 | 中文国产成人精品久久96 | 国产精品91视频 | 成人免费视频在线看 | 亚洲日本一区二区三区在线不卡 | 色豆豆永久免费网站 | 亚洲图片色图 | 成人观看视频 | 国产成人手机视频 | 精品国产免费第一区二区 | 日韩视频免费 | 九一精品国产 | 男人天堂2020手机在线 | 亚洲国产aaa毛片无费看 | 欧美综合国产精品日韩一 | 免费国产小视频在线观看 | 欧美激情一区二区三区在线播放 | www精品视频 | 老黄网站在线观看免费 | 免费观看黄色视屏 | 精品国产免费福利片 | 九月婷婷人人澡人人添人人爽 | 日本高清中文字幕视频在线 | vvideos欧美极度另类 | 久久夜视频| 免费亚洲视频 | 网站在线观看你懂的 | 午夜在线免费观看 | 久草色视频 | 欧美成人精品免费播放 | 亚洲专区第一页 | 欧美18videosex性视频 | 操美女在线视频 | 亚洲精品成人中文网 |