空手道 API 测试 @RunWith(Karate.class) 错误

Karate API Testing @RunWith(Karate.class) Errror

你好,这是我第一次尝试自己的 API 测试,但我有点困惑。

我想测试 DataCycle API 是否可用并给出正确的结果,但我收到 Karate.class

的类型不匹配错误

有人能找出我的错误吗?

这是我的功能文件,我想检查它的 运行

Feature: Karate testing DataCycle API

  Scenario: Verify DataCycle is up and running
  
    Given url https://datacycle.visitklagenfurt.at/api/v4/universal
    When method get
    Then status 200
package examples;

import org.junit.runner.RunWith;

import com.intuit.karate.junit5.Karate;

@RunWith(Karate.class)
public class Demo1 {

}

老实说,显然一切都可能是非常错误的,因为我是 API 测试的新手

这是 HTTP-GET url:https://datacycle.visitklagenfurt.at/api/v4/endpoints/f9ef0685-36bd-404f-b53a-db52adc86d7c?token=04f9e0d4dd87173d29ebc9c7d1c64ac8

我的pom.xml文件:

 <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
        <maven.compiler.version>3.8.1</maven.compiler.version>
        <maven.surefire.version>2.22.2</maven.surefire.version>        
        <karate.version>0.9.6</karate.version>
    </properties>    

    <dependencies>         
        <dependency>
            <groupId>com.intuit.karate</groupId>
            <artifactId>karate-apache</artifactId>
            <version>${karate.version}</version>
            <scope>test</scope>
        </dependency>       
          
        <dependency>
            <groupId>com.intuit.karate</groupId>
            <artifactId>karate-junit5</artifactId>
            <version>${karate.version}</version>
            <scope>test</scope>
        </dependency>       
    </dependencies>

    <build>
        <testResources>
            <testResource>
                <directory>src/test/java</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.version}</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <compilerArgument>-Werror</compilerArgument>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven.surefire.version}</version>
                <configuration>
                    <argLine>-Dfile.encoding=UTF-8</argLine>
                </configuration>
            </plugin>          
        </plugins>        
    </build>       
    
</project>

@RunWith(Karate.class) 仅适用于 JUnit 4。

请从快速入门开始:https://github.com/intuit/karate#quickstart

或者 ZIP 版本可能会更简单:https://github.com/intuit/karate/wiki/ZIP-Release