'"TestNG No tests found. Nothing was run" while executing automated tests using Selenium through TestNG
I want to know what exact software should I install before I run my automation project. Selenium web driver, selenium java, testNG, junit was installed but there are some problems with that also. 1. Selenium java file doesn't have more JAR files like people shows in their video tutorials. 2. When I' going to run my project as testNG, eclipse said windows firewall has blocked some features of this app.
Solution 1:[1]
This error message...
[TestNG] No tests found. Nothing was run
...implies that TestNG didn't find any @Test
to execute.
Your main issue is though you have imported Test
as:
import org.testng.annotations.Test;
But your code block has no @Test
as such but includes a @BeforeClass
. As there are no tests, TestNG doesn't find any Test to execute.
Solution
The easiest solution would be to change the @BeforeTest
annotation with @Test
and execute you Test case / Test Suite.
Solution 2:[2]
Because your main method have been put under beforeclass annotation. The main method does not take any annotation. If you provide any TestNG annotation to the main method then this error is thrown. When using TestNG you don't write a main method. It is not that main method along with other tests with @test annotation will not run, it is just that the main method does not take any annotation. It is only the non-main methods that take TestNG annotations. If you have a regular java main method and the other @test methods in the same class, the program will compile and run successfully but the main method will be ignored and won't run at all. It is only the other @test methods that will run.
Solution 3:[3]
Firstly,annotation @BeforeClass is not a "@Test" ,it only works as a clue or guidelines for the execution of the actual "@Test". Replace @BeforeClass with @Test, and again replace (public static void main(String[]args) with "public void guru99()" or "public static void guru99()".
Solution 4:[4]
I encountered this error when my test
(@Test
annotated) methods in my Groovy TestNG test class were declared using the def
method syntax from Groovy. TestNG does let you write your test methods in Groovy but it gripes if they don't have the usual Java declared syntax.
Not this:
@Test
def testDoWork {
...
Do this:
@Test
public void testDoWork {
...
Set it back to @Test public void testMethodName() {
syntax and you'll be good again.
Solution 5:[5]
This error may also occur when we tried to run TestNG testcase without fixing build path error in the project.(testNG jar was added after project configuration..)
So you will not get compile time error for any TestNG annotations used but when trying to run the code you will fall into this error as Project will be unable to build the properties of TestNG until you get rid of build path errors....
Resolution:
1.check if annotations are properly used.
2.check if any build path error exist in the project. if yes then resolve the issue in your build path and then give another try.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Moshe Slavin |
Solution 2 | |
Solution 3 | KOFI O. |
Solution 4 | dan |
Solution 5 | Aditya Shastri |