@Test public void testMethod() { int a = 10; int b = 20; if(a > b) { Assert.fail("a is greater than b"); } }
@Test public void testMethod() { String str = "hello"; if(str.equals("world")) { Assert.fail("str is equal to world"); } }
@Test public void testMethod() { ArrayListIn this example, the test case will be purposely failed and the message "Error - array list is empty" will be displayed as the ArrayList is empty. Package library: org.testng.list = new ArrayList (); Assert.fail("Error - array list is empty"); }