Commit 53c51bee authored by Đỗ Gia Hưng's avatar Đỗ Gia Hưng

Bai 10: Cach su dung Annotation trong TestNG (priority, description, enabled)

parent 2429975d
......@@ -25,22 +25,29 @@ public class TestNGAnnotationsTest {
System.out.println("- @BeforeMethod: Chay truoc moi phuong thuc @Test");
}
@Test
// Bai 10: Su dung thuoc tinh priority de quan ly thu tu chay (so nho chay truoc)
// description dung de mo ta test case giup bao cao de doc hon
@Test(priority = 1, description = "Kiem tra tieu de trang web Anh Tester")
public void testCase1() {
System.out.println("Executing Test Case 1");
System.out.println("Executing Test Case 1: Kiem tra tieu de");
String expectedTitle = "Anh Tester";
String actualTitle = "Anh Tester";
// Su dung Assertion de kiem tra ket qua
Assert.assertEquals(actualTitle, expectedTitle, "Tieu de khong khop!");
}
@Test
@Test(priority = 2, description = "Kiem tra trang thai hien thi cua phan tu")
public void testCase2() {
System.out.println("Executing Test Case 2");
System.out.println("Executing Test Case 2: Kiem tra hien thi");
boolean isDisplayed = true;
Assert.assertTrue(isDisplayed, "Phan tu khong hien thi!");
}
// Bai 10: Su dung enabled = false de bo qua (skip) mot test case khong muon chay
@Test(priority = 3, enabled = false, description = "Test case nay dang bi loi nen tam thoi bo qua")
public void testCase3() {
System.out.println("Test case nay se khong bao gio duoc chay");
}
@AfterMethod
public void afterMethod() {
System.out.println("- @AfterMethod: Chay sau moi phuong thuc @Test");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment