简体   繁体   English

Selenium TestnNg - AssertAll() 应该放在测试中的哪个位置

[英]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. I am working on Page Object Model framework in the Selenium -TestNG using Java in Eclipse IDE. I have my base class, pages and test classes ready.我已经准备好基础 class、页面和测试类。 In my test, I am using SoftAssert class as I want my test to continue even when they fail.在我的测试中,我使用 SoftAssert class 因为我希望即使测试失败也能继续进行。 In the end I do SoftAssert.assertAll().最后我做了 SoftAssert.assertAll()。

Everything works fine.一切正常。

But ideally where should assertAll method be executed?但理想情况下应该在哪里执行 assertAll 方法?

  1. In the last test method (@Test) which is going to get executed in that class?在 class 中执行的最后一个测试方法 (@Test) 中? 2)AfterClass 3)AfterSuite 2)AfterClass 3)AfterSuite

As per ur comment @AfterTest?根据你的评论@AfterTest? what you meant by @AfterTest? @AfterTest 是什么意思?

@BeforeTest and @AfterTest are respective to test (<test>... </test>) in testng.xml file @BeforeTest 和 @AfterTest 分别用于测试 testng.xml 文件中的(<test>... </test>)

simply use SoftAssert softAssertion= new SoftAssert();只需使用 SoftAssert softAssertion= new SoftAssert(); at start of @Test and softAssertion.assertAll();在 @Test 和 softAssertion.assertAll() 开始时; at end最后

@Test
public void softAssert(){
    SoftAssert softAssertion= new SoftAssert();
    //..............
    //..............
    softAssertion.assertAll();
}

go through doc to learn more on testng https://testng.org/doc/documentation-main.html go 通过 doc 了解更多关于 testng https://testng.org/doc/documentation-main.ZFC35FDC70D52CA78A9

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM