Java 空手道BDD框架,配置简单
我试图使用空手道BDD框架在我的API套件上运行测试,我遇到了一个NPE。据我所知,我没有误解任何东西,但我肯定我忽略了一些东西。鉴于下面的功能文件和任务运行程序,是否有我做错的事情 更新:这适用于空手道0.2.9,但不是当前最新的0.5.0.2 功能文件:…/src/test/resources/root/Feature/sanity.FeatureJava 空手道BDD框架,配置简单,java,bdd,karate,Java,Bdd,Karate,我试图使用空手道BDD框架在我的API套件上运行测试,我遇到了一个NPE。据我所知,我没有误解任何东西,但我肯定我忽略了一些东西。鉴于下面的功能文件和任务运行程序,是否有我做错的事情 更新:这适用于空手道0.2.9,但不是当前最新的0.5.0.2 功能文件:…/src/test/resources/root/Feature/sanity.Feature Feature: Sanity Check As a developer I want to ensure that the test
Feature: Sanity Check
As a developer
I want to ensure that the test framework is active
So that I can be confident I am testing correctly
Background:
* url httpBin
Scenario: httpBin reflection
Given path '/anything/foo/bar?baz=quux'
When method GET
Then status 200
And match response contains { "args": {"baz":"quux"}}
And match response contains { "method": "GET" }
驱动程序:…/src/test/java/root/feature/sanity/SmokeTest.java
package root.feature.sanity;
import com.intuit.karate.junit4.Karate;
import cucumber.api.CucumberOptions;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
/**
* Created by williamspaul on 8/29/17.
*/
@RunWith(Karate.class)
@CucumberOptions(plugin = {"pretty", "html:target/cucumber"})
public class SmokeTest {
@BeforeClass
public static void beforeClass() {}
@AfterClass
public static void afterClass() {}
}
mvn测试输出
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running root.feature.sanity.SmokeTest
10:46:08.568 [main] DEBUG com.intuit.karate.cucumber.CucumberRunner - init test class: class apigee.feature.sanity.SmokeTest
10:46:08.680 [main] DEBUG com.intuit.karate.cucumber.CucumberRunner - loading feature: /(private-path)/target/test-classes/root/feature/sanity/sanity.feature
Feature: Sanity Check
As a developer
I want to ensure that the test framework is active
So that I can be confident I am testing correctly
Background: # apigee/feature/sanity/sanity.feature:6
* url httpBin
0 Scenarios
0 Steps
0m0.000s
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.389 sec <<< FAILURE!
Feature: Sanity Check Time elapsed: 0.11 sec <<< ERROR!
java.lang.NullPointerException
at com.intuit.karate.cucumber.CucumberUtils.afterStep(CucumberUtils.java:148)
at com.intuit.karate.cucumber.CucumberUtils.runStep(CucumberUtils.java:140)
at com.intuit.karate.cucumber.KarateRuntime.runStep(KarateRuntime.java:51)
at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
at cucumber.runtime.model.CucumberScenario.runBackground(CucumberScenario.java:59)
at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:42)
at cucumber.runtime.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:102)
at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:63)
at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:18)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:70)
at com.intuit.karate.junit4.Karate.runChild(Karate.java:60)
at com.intuit.karate.junit4.Karate.runChild(Karate.java:25)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at com.intuit.karate.junit4.Karate.run(Karate.java:66)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Results :
Tests in error:
Feature: Sanity Check
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
-------------------------------------------------------
T T S T S
-------------------------------------------------------
正在运行root.feature.sanity.SmokeTest
10:46:08.568[main]调试com.intuit.karate.cucumber.CucumberRunner-初始化测试类:类apigee.feature.sanity.SmokeTest
10:46:08.680[main]DEBUG com.intuit.karate.cucumber.CucumberRunner-加载功能:/(私有路径)/目标/测试类/根/功能/健全性/健全性.feature
功能:健全性检查
作为开发者
我想确保测试框架是活动的
这样我就可以确信我的测试是正确的
背景:#apigee/feature/santy/santy.feature:6
*url-httpBin
0场景
0步
0m0.000s
测试运行:1,失败:0,错误:1,跳过:0,运行时间:0.389秒您实际使用的是测试版。只要使用0.5.0,您就会没事
顺便说一句,非常感谢您找到了这一点,这一点在development分支中得到了解决:
另外,请务必查看有关为什么需要此前/后步骤挂钩的详细信息0.5.0导致运行时异常,即无法构造名为“karate http.properties”的类,必须包含karate apache依赖项并添加karate-http.properties文件,而不是文档中的文件。所有内容都在文档中。您不需要手动属性文件。把它取下来,看看。。可能还需要有空手道apache依赖项。