-
Show us your pom.xml– Alexey R.Commented Aug 23, 2020 at 19:11
-
<dependency> <groupId>io.rest-assured</groupId> <artifactId>rest-assured</artifactId> <version>4.1.2</version> <scope>test</scope> </dependency> <!-- mvnrepository.com/artifact/org.testng/testng --> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.14.3</version> </dependency> <dependency> <groupId>com.github.scribejava</groupId> <artifactId>scribejava-apis</artifactId> <version>2.5.3</version> <scope>test</scope> </dependency>– Ashutosh SinghCommented Aug 23, 2020 at 19:18
-
<version>6.14.3</version> TestNg Version– Ashutosh SinghCommented Aug 23, 2020 at 19:19
-
Just put your pom to your question. not to comments. Including plugins section.– Alexey R.Commented Aug 23, 2020 at 19:19
-
Added my POM in ques– Ashutosh SinghCommented Aug 23, 2020 at 19:21
4 Answers
This error message implies that TestNG didn't find any @Test
to execute.
[TestNG] No tests found. Nothing was run
Make sure you have imported Test
annotation & used @Test
to execute.
import org.testng.annotations.Test;
-
I have imported the correct dependecy import static io.restassured.RestAssured.*; import static org.hamcrest.Matchers.*; import org.testng.annotations.Test; import io.restassured.RestAssured; import io.restassured.response.Response; import io.restassured.specification.RequestSpecification; Commented Aug 24, 2020 at 4:54
-
Are you using the @Test annotation in the script to execute test? Commented Aug 24, 2020 at 5:31
-
-
Share the code snippet .... are you using annotation in the main method? Commented Aug 24, 2020 at 6:08
-
because the main method does not take any annotation. If you provide any TestNG annotation to the main method then you will get the same error. Commented Aug 24, 2020 at 6:10
As per your code reference testng.xml and your test class there is no method getTestNgTest1
inside the class com.rest.api.authentications.OAuth2APITest
Change the testng.xml
to the below one probably it will work
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite guice-stage="DEVELOPMENT" name="Default suite">
<test thread-count="5" verbose="2" name="Default test">
<classes>
<class name="com.rest.api.authentications.OAuth2APITest" />
</classes>
</test> <!-- Default test -->
</suite> <!-- Default suite -->
-
-
@AshutoshSingh I made a run from my local machine with your sample code and my updated
testng.xml
works fine for me. Try by addingscope
to your testng dependency inpom.xml
file and atlast make restart to your IDE. Make cross verify whether the dependencies are loaded to your project from POM file not from the Jar file in buildpath which you may have added unknowingly Commented Aug 24, 2020 at 7:36 -
I have added and follow the instruction but still not working pom.xml link gist.github.com/asingh4305/4870d1cd56b6112495255934306000cd Commented Aug 24, 2020 at 8:12
Your pom.xml
has to include maven surefire
plugin inside <build>...</build>
tags:
<properties>
...
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
...
</dependencies>
Then you can execute your tests by running mvn test
.
Bare in mind it will pick up every class that has a ...test
suffix and look for methods annotated with @Test
only in such classes.
How to execute a single test (question in comments):
You can provide method name in testng.xml
file, like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="testSuite" verbose="1">
<test name="tests">
<classes>
<class name="className">
<methods>
<include name="testMethodName"></include>
</methods>
</class>
</classes>
</test>
</suite>
Or simply run it via maven:
mvn test -Dtest=className#methodName
When executing a single test via maven, you might need to add -DfailIfNoTests=false
so that maven does not fail, when multiple modules exist.
-
Correct i want to run only single test at a time... Not entire build Commented Aug 26, 2020 at 7:29
-
I have updated my answer with information on running a single test.– MoroCommented Aug 26, 2020 at 8:03
-
mvn test -Dtest=className#methodName Its worked ..thanks Commented Aug 26, 2020 at 12:11
-
If my answer helped you, please mark it as solved, so that others can use it as reference.– MoroCommented Aug 27, 2020 at 7:06