Similar Posts


  1. Is there a way to combine both Hard and Soft Assertions in one method?

    Here’s an example:

    public void testMethod() {
    softAssert.assertEquals(“test”, “not test”, “This shoud fail”);
    hardAssert.assertTrue(false, “This should fail, too”);

    When I run this code, only the hardAssert gets reported because it already throws an exception. If I call on softAssert.assertAll() before hardAssert.assertTrue(), it only reports the softAssert failures.

    I would like for both failures in hard and soft assertions to be reported when the test completes.

    Thanks in advance!

  2. My Test is getting failed when there is no assert :

    //Create an object for SoftAssert
    public static SoftAssert sa= new SoftAssert();

    public static void oracleTest()
    if(5 > 3)

  3. I am sorry,

    Its my mistake in the code, Instead of “sa.notifyAll();” I need to write “sa.AssertAll();”

    Thanks Raj for your write up on Soft Assertions

  4. lets say we have 5 assert statement in soft assert and 2 and 4 assert are failing after Assert all, I want to know exactly which assert statement failed and get email for that currently I am using it in after method but unable to get details on exactly which step it has failed.
    ITestResult doesn’t have that option is there any work around which you could suggest?
    public void closeBrowser(ITestResult result) throws EmailException

    if(ITestResult.FAILURE==result.getStatus()) {
    EmailPage.sendFailedEmail(ProperyReader.getProperty(“ukNonMemberEmailId”), ProperyReader.getProperty(“emailPassword”), ProperyReader.getProperty(“sendEmailTo”),result.getName());

  5. Hi,
    can any one tell me the real time usage of BeforeTest and BeforeClass methods in Selenium script?when do we use these Methods .what kind of logics do we keep in these methods?

Leave a Reply

Your email address will not be published. Required fields are marked *