Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Automation_selenium
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Trình Nguyễn
Automation_selenium
Commits
2429975d
Commit
2429975d
authored
May 05, 2026
by
Đỗ Gia Hưng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bai 9: Cai dat va su dung TestNG Framework
parent
a58ae2dc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
0 deletions
+74
-0
TestNGAnnotationsTest.java
.../java/com/automation/testcases/TestNGAnnotationsTest.java
+63
-0
testng.xml
testng.xml
+11
-0
No files found.
src/test/java/com/automation/testcases/TestNGAnnotationsTest.java
0 → 100644
View file @
2429975d
package
com
.
automation
.
testcases
;
import
org.testng.Assert
;
import
org.testng.annotations.*
;
public
class
TestNGAnnotationsTest
{
@BeforeSuite
public
void
beforeSuite
()
{
System
.
out
.
println
(
">>> @BeforeSuite: Chay 1 lan duy nhat truoc toan bo Suite"
);
}
@BeforeTest
public
void
beforeTest
()
{
System
.
out
.
println
(
">> @BeforeTest: Chay truoc cac class trong 1 the <test>"
);
}
@BeforeClass
public
void
beforeClass
()
{
System
.
out
.
println
(
"> @BeforeClass: Chay truoc class hien tai"
);
}
@BeforeMethod
public
void
beforeMethod
()
{
System
.
out
.
println
(
"- @BeforeMethod: Chay truoc moi phuong thuc @Test"
);
}
@Test
public
void
testCase1
()
{
System
.
out
.
println
(
"Executing Test Case 1"
);
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
public
void
testCase2
()
{
System
.
out
.
println
(
"Executing Test Case 2"
);
boolean
isDisplayed
=
true
;
Assert
.
assertTrue
(
isDisplayed
,
"Phan tu khong hien thi!"
);
}
@AfterMethod
public
void
afterMethod
()
{
System
.
out
.
println
(
"- @AfterMethod: Chay sau moi phuong thuc @Test"
);
}
@AfterClass
public
void
afterClass
()
{
System
.
out
.
println
(
"> @AfterClass: Chay sau class hien tai"
);
}
@AfterTest
public
void
afterTest
()
{
System
.
out
.
println
(
">> @AfterTest: Chay sau cac class trong 1 the <test>"
);
}
@AfterSuite
public
void
afterSuite
()
{
System
.
out
.
println
(
">>> @AfterSuite: Chay 1 lan duy nhat sau toan bo Suite"
);
}
}
testng.xml
0 → 100644
View file @
2429975d
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite
name=
"Suite Bài 9 TestNG"
>
<test
name=
"Test Selenium Cơ bản"
>
<classes>
<class
name=
"com.automation.testcases.BasicWebDriverCommandsTest"
/>
<class
name=
"com.automation.testcases.WebElementCommandsTest"
/>
<class
name=
"com.automation.testcases.TestNGAnnotationsTest"
/>
</classes>
</test>
</suite>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment