2

enter image description here CucumberFeature feature = wrapper.getCucumberFeature(); // extentReportHelper.CreateTest(wrapper.toString(),"just for test");

    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);

The above steps are per design in the class.feature.run() runs the scenario and give the result pass or fail. I need capture log for every step output and attached to the report. I want to change the code to run step by step capture the logs in my customized report. Please can someone suggest to me how can I capture the logs with below code.

 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());
            }
        }

This approach is throwing below error. Please let me know, how can execute step by step.

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)
rama
  • 75
  • 6
  • i want create report like above picture. for(int scecnt=0;scecnt – rama Aug 12 '18 at 12:46
  • this is not supported by Karate. please note that we are re-writing the engine. Karate is NOT Cucumber. if you want to go down this path, you are on your own: https://github.com/intuit/karate/issues/444 – Peter Thomas Aug 12 '18 at 12:48
  • please note that we plan to deprecate TestNG support also: https://twitter.com/KarateDSL/status/1025067559027179521 – Peter Thomas Aug 12 '18 at 16:44
  • Let me know if there is any way to publish karate report in Klov server or Extent report.Thanks for your support – rama Aug 12 '18 at 17:20
  • I have no idea about Klov server, sorry. – Peter Thomas Aug 12 '18 at 17:22

1 Answers1

0

It is not clear what you are trying to do, and you seem to be using Karate internal API-s which are not intended for use by others. These will change in future.

Please follow the instructions here and explain what exactly you need if you need help: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

Also see Karate hooks: 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 });
}
"""
Peter Thomas
  • 54,465
  • 21
  • 84
  • 248