空手道 API 测试 @RunWith(Karate.class) 错误 [英] Karate API Testing @RunWith(Karate.class) Errror
问题描述
您好,这是我第一次尝试自己的 API 测试,但我有点困惑.
我想测试 DataCycle API 是否可用并给出正确的结果,但我收到了 Karate.class 的类型不匹配错误
有人能发现我的错误吗?
这是我的功能文件,我想检查它是否正在运行
功能:空手道测试 DataCycle API场景:验证 DataCycle 是否已启动并正在运行给定网址 https://datacycle.visitklagenfurt.at/api/v4/universal当方法得到然后状态 200
包示例;导入 org.junit.runner.RunWith;导入 com.intuit.karate.junit5.Karate;@RunWith(Karate.class)公共类Demo1 {}
说实话,很明显,一切都可能是非常错误的,因为我是 API 测试的新手
这是 HTTP-GET 网址:https://datacycle.visitklagenfurt.at/api/v4/endpoints/f9ef0685-36bd-404f-b53a-db52adc86d7c?token=04f9e0d4dd87173d29ebc9c7d1c64ac8
我的 pom.xml 文件:
<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></属性><依赖项><依赖><groupId>com.intuit.karate</groupId><artifactId>空手道-apache</artifactId><version>${karate.version}</version><范围>测试</范围></依赖><依赖><groupId>com.intuit.karate</groupId><artifactId>空手道-junit5</artifactId><version>${karate.version}</version><范围>测试</范围></依赖></依赖项><构建><测试资源><测试资源><目录>src/test/java</directory><排除><exclude>**/*.java</exclude></排除></testResource></testResources><插件><插件><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>${maven.compiler.version}</version><配置><encoding>UTF-8</encoding><source>${java.version}</source><target>${java.version}</target><compilerArgument>-Werror</compilerArgument></配置></插件><插件><groupId>org.apache.maven.plugins</groupId><artifactId>maven-surefire-plugin</artifactId><version>${maven.surefire.version}</version><配置><argLine>-Dfile.encoding=UTF-8</argLine></配置></插件></plugins></build></项目>
@RunWith(Karate.class)
仅适用于 JUnit 4.
请从快速入门开始:https://github.com/intuit/karate#quickstart
也许 ZIP 版本会更简单:https://github.com/直觉/空手道/wiki/ZIP-Release
Hello this is my first time trying an own API testing but I'm a little bit confused.
I want to test if DataCycle API is available and gives correct results, but i'm getting the Type mismatch error for Karate.class
Can someone find my mistake?
This is my feature file where i wanna check is its running
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 {
}
To be honest everything could be terribly wrong obviously because I am new to API testing
This is the HTTP-GET url: https://datacycle.visitklagenfurt.at/api/v4/endpoints/f9ef0685-36bd-404f-b53a-db52adc86d7c?token=04f9e0d4dd87173d29ebc9c7d1c64ac8
my pom.xml file:
<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)
is only for JUnit 4.
Please just start with the quickstart: https://github.com/intuit/karate#quickstart
Or maybe the ZIP release will be simpler: https://github.com/intuit/karate/wiki/ZIP-Release
这篇关于空手道 API 测试 @RunWith(Karate.class) 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!