运行 通过 junit 的空手道特征文件
Running Karate Feature Files through junit
我在 src/test/java
中对我的 spring api 项目进行了 junit 测试。为了测试控制器,我创建了一个包 com.example.controller
,其中包含我的空手道功能文件 sample.feature:
Feature: sample
Scenario: Test Create
Given path '/test'
Given url 'https://localhost:8443'
When method GET
Then status 200
下面是我的测试class:
package com.example.controller;
import com.intuit.karate.junit5.Karate;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
public class ControllerTest {
@Karate.Test
Karate testSample() {
return Karate.run("sample").relativeTo(getClass());
}
}
对于上述设置,我收到以下错误:
org.opentest4j.AssertionFailedError: http call failed after 105 milliseconds for url: https://localhost:8443/test
为了执行,我使用 mvn clean test -Dtest=ControllerTest
我的 pom.xml 中有 karate-core:1.0.1
和 karate-junit5:1.0.1
,还有空手道包中的 junit 排除项。我想在我的应用程序 运行ning 时 运行 空手道功能文件,类似于其他 junits 的执行方式。
在这种情况下我可能遗漏/配置不正确的任何内容?
参考 link 来自 Karate Project.
我认为 @Karate.Test
与 @SpringBootTest
不兼容,因此您可能需要自己解决这个问题。
提示 - 空手道 JUnit 支持只是一种便利,并非强制使用。您可以使用空手道“核心”Runner
class.
创建与 @SpringBootTest
配合良好的合理测试套件
详细解释见:
我在 src/test/java
中对我的 spring api 项目进行了 junit 测试。为了测试控制器,我创建了一个包 com.example.controller
,其中包含我的空手道功能文件 sample.feature:
Feature: sample
Scenario: Test Create
Given path '/test'
Given url 'https://localhost:8443'
When method GET
Then status 200
下面是我的测试class:
package com.example.controller;
import com.intuit.karate.junit5.Karate;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
public class ControllerTest {
@Karate.Test
Karate testSample() {
return Karate.run("sample").relativeTo(getClass());
}
}
对于上述设置,我收到以下错误:
org.opentest4j.AssertionFailedError: http call failed after 105 milliseconds for url: https://localhost:8443/test
为了执行,我使用 mvn clean test -Dtest=ControllerTest
我的 pom.xml 中有 karate-core:1.0.1
和 karate-junit5:1.0.1
,还有空手道包中的 junit 排除项。我想在我的应用程序 运行ning 时 运行 空手道功能文件,类似于其他 junits 的执行方式。
在这种情况下我可能遗漏/配置不正确的任何内容?
参考 link 来自 Karate Project.
我认为 @Karate.Test
与 @SpringBootTest
不兼容,因此您可能需要自己解决这个问题。
提示 - 空手道 JUnit 支持只是一种便利,并非强制使用。您可以使用空手道“核心”Runner
class.
@SpringBootTest
配合良好的合理测试套件
详细解释见: