首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >空手道API测试@RunWith(Karate.class)错误

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

Stack Overflow用户
提问于 2021-07-08 07:52:28
回答 1查看 752关注 0票数 1

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

我想测试DataCycle API是否可用并给出正确的结果,但是我得到了Karate.class的类型错配错误

有人能发现我的错误吗?

这是我要检查的功能文件,它正在运行。

代码语言:javascript
复制
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
代码语言:javascript
复制
package examples;

import org.junit.runner.RunWith;

import com.intuit.karate.junit5.Karate;

@RunWith(Karate.class)
public class Demo1 {

}

老实说,很明显,每件事都可能是非常错误的,因为我对API测试并不熟悉。

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

我的pom.xml文件:

代码语言:javascript
复制
 <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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-07-08 10:14:19

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

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

或者,ZIP发行版会更简单:https://github.com/intuit/karate/wiki/ZIP-Release

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68297610

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档