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,750 points
183 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,890 points
2,474 views
0 votes
0 answers

Getting Java Null Pointer Exception on running the test case in Seleniumn.Can someone pls let me know where i need to fix in order to progress

Below is the Error: java.lang.RuntimeException: java.lang.NullPointerException at org.testng.internal.MethodInvocationHelper.invokeMethodNoCheckedException(MethodInvocationHelper.java:49) at org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:131) at ...READ MORE

Sep 11 in Selenium by sandhya
• 180 points
249 views
0 votes
1 answer
0 votes
2 answers

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,520 points
3,769 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31 in Selenium by Sri
• 2,970 points
4,751 views
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,890 points
2,730 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 2 in Selenium by Sri
• 2,970 points
3,093 views
0 votes
1 answer
0 votes
1 answer