繁体   English   中英

RestAssured - TestNG“没有找到测试。没有运行”

[英]RestAssured - TestNG "No tests found. Nothing was run"

我想用 TestNG 测试我的 api 对 RestAssured 的使用,但我得到了一些错误。“没有测试是 [TestNG] 没有找到测试。没有运行”。 所以这是我的 pom.xml 文件和 testng.xml 文件。

Pom.xml

    <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>LifeboxAutomation</groupId>
    <artifactId>LifeboxAutomation</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>
    <dependencies>
        <!-- https://mvnrepository.com/artifact/io.rest-assured/rest-assured -->
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
            <version>4.4.0</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.testng/testng -->
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.14.3</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest -->
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest</artifactId>
            <version>2.2</version>
        </dependency>


    </dependencies>


</project>

testng.xml

    <?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="All Test Suite">
    <test verbose="2" name="C:/Users/EXT02D49935/IdeaProjects/LifeboxAutomation">
        <classes>
            <class name="PreReq.payload">
                <methods>
                    <include name="userAuth"/>
                </methods>
            </class>
            <class name="Album">
            </class>
        </classes>
    </test>
</suite>

测试NG配置

我的主要课程的一部分

感谢您的时间

好的,我删除了 psvm 的 @test。 我刚刚添加了@test 我的另一个类,如下所示:

    package PreReq;
import io.restassured.RestAssured;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.Test;

import static io.restassured.RestAssured.*;
import static org.hamcrest.Matchers.*;


public class payload {

    @Test
    public static String userAuth(){

并像这样重命名 testng 配置名称:

重命名 testNG 配置

但我仍然有错误

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM