需要与空手道徒手一步一步跑

时间:2018-08-12 03:32:05

标签: karate

enter image description here CucumberFeature功能= wrapper.getCucumberFeature();        // scopeReportHelper.CreateTest(wrapper.toString(),“仅用于测试”);

    File file = FileUtils.resolveIfClassPath(feature.getPath(), runtimeOptions.getClassLoader());
    KarateRuntime runtime = runtimeOptions.getRuntime(file, null);
    resultListener.startFeature();
    RuntimeOptions ro = runtimeOptions.getRuntimeOptions();
    int scenario=feature.getFeatureElements().size();
    feature.run(ro.formatter(runtimeOptions.getClassLoader()), resultListener, runtime);

以上步骤是按类中的每个设计进行的。feature.run()运行方案并给出结果是否通过。我需要每个步骤输出的捕获日志并附加到报告中。 我想更改代码以逐步运行以捕获自定义报告中的日志。请有人可以向我建议如何使用以下代码捕获日志。

 for(int scecnt=0;scecnt<scenario;scecnt++) {
            int getstepcnt=feature.getFeatureElements().get(0).getSteps().size();
            for (int stepcnt=0;stepcnt<getstepcnt;stepcnt++) {
            //   runtime.runStep(feature.getPath(),feature.getFeatureElements().get(scecnt).getSteps().get(stepcnt), resultListener ,feature.getI18n());
            }
        }

此方法抛出以下错误。请让我知道,如何逐步执行。

java.lang.NullPointerException
    at com.intuit.karate.cucumber.KarateRuntime.addStepToCounterAndResult(KarateRuntime.java:69)
    at com.intuit.karate.cucumber.KarateRuntime.runStep(KarateRuntime.java:96)
    at com.intuit.karate.testng.KarateRunner.feature(KarateRunner.java:81)
    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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:643)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:820)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1128)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
    at org.testng.TestRunner.privateRun(TestRunner.java:782)
    at org.testng.TestRunner.run(TestRunner.java:632)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
    at org.testng.SuiteRunner.run(SuiteRunner.java:268)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1244)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1169)
    at org.testng.TestNG.run(TestNG.java:1064)
    at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
    at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123)

1 个答案:

答案 0 :(得分:0)

目前尚不清楚您要做什么,并且您似乎正在使用不适合其他人使用的Karate内部API。这些将来会改变。

请按照此处的说明进行操作,并在需要帮助的情况下解释您真正需要什么:https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

另请参阅空手道挂钩:https://github.com/intuit/karate#hooks

* configure afterScenario = 
"""
function(){
  var info = karate.info; 
  karate.log('after', info.scenarioType + ':', info.scenarioName);
  karate.call('after-scenario.feature', { caller: info.featureFileName });
}
"""