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,760 points
3,125 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,910 points
5,867 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, 2020 in Selenium by sandhya
• 180 points
12,655 views
0 votes
1 answer

How to run test case using TestNG

I am assuming that you want to ...READ MORE

answered Jan 8, 2019 in Selenium by Nabarupa
1,484 views
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,500 points
13,676 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

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

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,144 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,910 points
7,221 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 3, 2020 in Selenium by Sri
• 3,190 points
7,875 views
0 votes
1 answer
0 votes
1 answer

How to disable a test case in testNG?

You can use the enable method to ...READ MORE

answered Jan 3, 2019 in Selenium by Nabarupa
2,151 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP