Test getting pass in soft assertion

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Test getting pass in soft assertion

vivek.vs
Hi Tarun,

I have tried Soft assertion and my test is getting passed.
It is showing test passed (in green) in soft assertion

method:

public static void raiseException(String exp, String act) {
                try {
                        takeSnapShot();
                        //Assert.fail("Page did not open");
                        Assert.assertTrue(exp.equalsIgnoreCase(act));
                } catch (Error t) {
                        errcol.append(t);
                        Reporter.log("Error: "+"expted: "+exp +" ; "+ "Actual: "+act);
                }
        }

After catching error, it is printing message in report but in console, it is showing test passed
Reply | Threaded
Open this post in threaded view
|

Re: Test getting pass in soft assertion

softwaretestingforum
Administrator
because you are catching the exception hence it does not fail
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Test getting pass in soft assertion

vivek.vs
Hi Tarun,

but in soft assertion tutorial, you are also catching the error and it was getting failed.

public void verifyEquals(String msg, String s1, String s2) {
                try {
                        Assert.assertEquals(s1, s2);
                } catch (Error e) {
                        verificationErrors.append(e);
                        Reporter.log(msg + "<br>");
                }
        }
Reply | Threaded
Open this post in threaded view
|

Re: Test getting pass in soft assertion

vivek.vs
In reply to this post by softwaretestingforum
Hi Tarun,

Can u please send me SeleneseTestBase.java file.
It is missing in selenium_project.zip file

Reply | Threaded
Open this post in threaded view
|

Re: Test getting pass in soft assertion

softwaretestingforum
Administrator
Hi Vivek,

SeleneseTestBase class was part of Selenium jar and should be in package -import com.thoughtworks.selenium.SeleneseTestBase;

Please see following post for more - http://www.seleniumtests.com/2008/09/soft-assertion-is-check-which-doesnt.html
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Test getting pass in soft assertion

vivek.vs
Thank you Tarun