如何在 TestNG 中使用正則表示式?
我們在 TestNG 中使用正則表示式處理一組以特定模式命名的測試方法。
示例
Testng xml 檔案。
<?xml version = "1.0" encoding = "UTF-8"?> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > <suite name = "Tutorialspoint Test "> <test name = "Test Cycle"> <classes> <class name = "TestRegularExpression" /> <methods> <exclude name= “Payment.*”/> </methods> </classes> </test> </suite>
所有以 Payment 開頭的測試方法都將從迴歸套件中排除。
示例
@Test
public void PaymentHistory(){
System.out.println("Payment history validation is successful”);
}
@Test
public void Login(){
System.out.println("Login is successful”);
}
@Test
public void PaymentDefault(){
System.out.println("Payment default verification is successful”);
}Login() 將被執行,但所有以 Payment 開頭的將從執行中排除。這是使用正則表示式(Payment.*)實現的。
廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式語言
C++
C#
MongoDB 資料庫
MySQL
Javascript
PHP