您的位置:軟件測試 > 開源軟件測試 > 開源單元測試工具 > TestNG
JUnit和TestNG的區(qū)別
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時(shí)間:[ 2014/8/18 14:36:36 ] 推薦標(biāo)簽:TestNG

  然后相應(yīng)的我們用@DataProvider來標(biāo)注一個(gè)方法,這個(gè)方法提供了數(shù)據(jù):
//This function will provide the patameter data
@DataProvider(name = "Data-Provider-Function")
public Object[][] parameterIntTestProvider() {
TestNGTest6_3_0 obj = new TestNGTest6_3_0();
obj.setMsg("Hello");
obj.setNumber(123);
return new Object[][]{
{obj}
};
}
  3.測試依賴性:
  對(duì)于JUnit 來說,所有的測試彼此之間都是獨(dú)立的,毫無依賴性。
  但是對(duì)于 TestNG來說,我們完全可以讓測試彼此之間有依賴性,做法是dependsOnMethods屬性來標(biāo)識(shí)一個(gè)被依賴的測試方法:
@Test
public void method1() {
System.out.println("This is method 1");
}
@Test(dependsOnMethods={"method1"})
public void method2() {
System.out.println("This is method 2");
}

上一頁12下一頁
軟件測試工具 | 聯(lián)系我們 | 投訴建議 | 誠聘英才 | 申請使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd