Test case not running on TestNG

0 votes

I am new to testNG and i wrote a program to check 3 test cases but only one is executing and the other 2 are not. Here is the code that I used.

package testNG;
import org.testng.annotations.Test;

public class AnnotationsDemo {
  @Test
  public void f1()
  {
      System.out.println("function1");
  }
  public void f2()
  {
      System.out.println("function2");
  }
  public void f3()
  {
      System.out.println("function3");
  }
}

I am not getting any error also. So I am unable to trace the error. Can someone please help? Thank you.

Dec 26, 2018 in Selenium by Sradha
• 1,720 points
73 views

1 answer to this question.

0 votes

Hello @Sradha, You are not getting any error because there are none.

Talking about the test case that is executed is the first one as you have made only f1 as a test case. You need to do that individually for all the other test cases also. Overall just by adding @test before the functions you want to run as test case you will get all of the above as a test case.

package testNG;
import org.testng.annotations.Test;

public class AnnotationsDemo {
  @Test
  public void f1()
  {
      System.out.println("function1");
  }
  @Test
  public void f2()
  {
      System.out.println("function2");
  }
  @Test
  public void f3()
  {
      System.out.println("function3");
  }
}

Output:-

answered Dec 26, 2018 by Trisha

Related Questions In Selenium

0 votes
1 answer

Error: TestNG @BeforeClass initialization code not running before Test

Below will help: @BeforeTest: The annotated method will ...READ MORE

answered Jul 6, 2018 in Selenium by Samarpit
• 5,130 points
864 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,090 points
551 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
888 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
550 views
0 votes
1 answer