1
UTF-8 io.rest-assured rest-assured 4.1.2 test org.testng testng 6.14.3 ************************************************** TestNg.xml

enter image description here

6
  • 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> Commented Aug 23, 2020 at 19:18
  • <version>6.14.3</version> TestNg Version Commented 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 Commented Aug 23, 2020 at 19:21

4 Answers 4

3

make sure you are importing org.testng.annotations.Test and not org.junit.Test

0

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;
10
  • 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
  • Yes, @Test public void getAPITest() { Commented Aug 24, 2020 at 5:40
  • 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
0

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 -->
3
  • Updated TestNg.xml but no Luck Still same issue . Commented Aug 24, 2020 at 7:00
  • @AshutoshSingh I made a run from my local machine with your sample code and my updated testng.xml works fine for me. Try by adding scope to your testng dependency in pom.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
0

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.

4
  • 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.
    – Moro
    Commented 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.
    – Moro
    Commented Aug 27, 2020 at 7:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.