“TestNG No tests found. Nothing was run” while executing automated tests using Selenium through TestNG

依然范特西╮ 提交于 2020-01-19 17:38:17

问题


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.


回答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.




回答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.



来源:https://stackoverflow.com/questions/56769978/testng-no-tests-found-nothing-was-run-while-executing-automated-tests-using-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!