Assertion in selenium webdriver -report showing only falied methods, not passed methods

130 views Asked by At

In my selenium TestNG class, there are some methods, like method1, method2 etc. I have added fail and success conditions to each method.

public class TestNGClass {

public void method1(String value) throws Exception {

  if(value.equals("PASS"){
      org.testng.Assert.assertTrue(condition, message);
  }
}

//This is another method

public void method2(String value) throws Exception {

  if(value.equals("FAIL"){
    org.testng.Assert.fail(message);
  }
}

But after the TestNG class execution, in the Test-Output folder "Index.html" will be created, which shows only the failed methods. How to display the passed methods also (custom report) .?

Thank you
1

There are 1 answers

0
optimistic_creeper On BEST ANSWER

Convert your test methods using @Test annotation. Modified Code Snippet:

public class TestNGClass {

@Test
public void method1(){
   Assert.assertTrue(condition, "Your Message goes here");
}

//This is another method
@Test
public void method2(){
  Assert.fail("Your Message goes here");
}

Now, you will have your testcases reported.