[英]Selenium TestnNg - where should AssertAll() be placed in the test
I am working on Page Object Model framework in the Selenium -TestNG using Java in Eclipse IDE. 我已經准備好基礎 class、頁面和測試類。 在我的測試中,我使用 SoftAssert class 因為我希望即使測試失敗也能繼續進行。 最后我做了 SoftAssert.assertAll()。
一切正常。
但理想情況下應該在哪里執行 assertAll 方法?
根據你的評論@AfterTest? @AfterTest 是什么意思?
@BeforeTest 和 @AfterTest 分別用於測試 testng.xml 文件中的(<test>... </test>)
只需使用 SoftAssert softAssertion= new SoftAssert(); 在 @Test 和 softAssertion.assertAll() 開始時; 最后
@Test
public void softAssert(){
SoftAssert softAssertion= new SoftAssert();
//..............
//..............
softAssertion.assertAll();
}
go 通過 doc 了解更多關於 testng https://testng.org/doc/documentation-main.ZFC35FDC70D52CA78A9
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.