您的位置:軟件測(cè)試 > 開源軟件測(cè)試 > 開源單元測(cè)試工具 > TestNG
APP接口自動(dòng)化測(cè)試JAVA+TestNG(2)?TestNG簡(jiǎn)介與基礎(chǔ)實(shí)例
作者:Findyou 發(fā)布時(shí)間:[ 2016/5/27 14:40:35 ] 推薦標(biāo)簽:單元測(cè)試工具 軟件測(cè)試

  2.2.2.5 執(zhí)行用例
  執(zhí)行:右擊JAVA文件,Run as -- > TestNG Test
  執(zhí)行結(jié)果:

  測(cè)試報(bào)告:

  瀏覽器查看:

  2.2.3 基礎(chǔ)實(shí)例2
  2.2.3.1 編寫測(cè)試用例
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
public class TestngStudy {
// test case 1
@Test
public void testCase1() {
System.out.println("This is a test case 1");
}
// test case 2
@Test
public void testCase2() {
System.out.println("This is a test case 2");
}
@BeforeMethod
public void beforeMethod() {
System.out.println("This is beforeMethod");
}
@AfterMethod
public void afterMethod() {
System.out.println("This is afterMethod");
}
@BeforeClass
public void beforeClass() {
System.out.println("This is beforeClass");
}
@AfterClass
public void afterClass() {
System.out.println("This is afterClass");
}
@BeforeTest
public void beforeTest() {
System.out.println("This is beforeTest");
}
@AfterTest
public void afterTest() {
System.out.println("This is afterTest");
}
@BeforeSuite
public void beforeSuite() {
System.out.println("This is beforeSuite");
}
@AfterSuite
public void afterSuite() {
System.out.println("This is afterSuite");
}
}
  2.2.3.2 執(zhí)行用例
[TestNG] Running:
C:UsersAlbertAppDataLocalTemp estng-eclipse--65898469 estng-customsuite.xml
This is beforeSuite
This is beforeTest
This is beforeClass
This is beforeMethod
This is a test case 1
This is afterMethod
This is beforeMethod
This is a test case 2
This is afterMethod
This is afterClass
This is afterTest
PASSED: testCase1
PASSED: testCase2
===============================================
Default test
Tests run: 2, Failures: 0, Skips: 0
===============================================
This is afterSuite
===============================================
Default suite
Total tests run: 2, Failures: 0, Skips: 0
===============================================
[TestNG] Time taken by org.uncommons.reportng.HTMLReporter@5f8ed237: 217 ms
  以上TestNG學(xué)習(xí)基本了解完畢,下一篇將通過對(duì)氣象局提供的天氣接口的測(cè)試,來講解HTTP接口的自動(dòng)化測(cè)試,與結(jié)果斷言。

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