Why Assert.fail("failing"); is not caught in catch block | Selenium Forum
M
Posted on 10/06/2016
Scenario: Am scripting for a scenario where a condition is checked & if nullpointer exception occurs in catch block another logic is written with respective catch blocks multiple times.[Try inside a catch block multiple times]

I want to forcefully make a exception caught in catch block.

class sonso{
void main()
{
try{
Assert.Fail("deliberately failing test");
}
catch(Exception e)
{
syso("in catch block");
}
}


[b:3i2zqf8u]Query:[/b:3i2zqf8u]Now this Assert.fail exception is never caught in catch block.Why sir?Any specific reason?
Should i try different exception lik arithmentexception herre?



}

M
Replied on 11/06/2016

Any assert will stop the execution and will not continue further, You need to use in catch block not in try block

Responsive image