Is there a way to mark a test as failed in the TestNG framework if a certain path is followed?
I know I can use system.exit(1); or something similar to mark an abnormal termination but it doesn't seem to actually mark the test as failed.
org.testng.Assert.fail("you wandered onto the wrong path");
You can always throw exception -
if("this path is followed") {
throw new Exception("was bound to fail!!!")
}
AssertionError instead of Exception (which is what Assert.fail() does under the covers) would be better and would prevent the error from being swallowed by a catch (Exception) block. Of course, catch (Exception) is generally a bad idea anyways...
– dimo414
Apr 06 '16 at 04:25
Assert.failed... – corsiKa Aug 29 '12 at 14:36