question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NPE on afterStep because KarateBackend.getVars() seems to return a null?

See original GitHub issue

Given a basic feature file and task runner (below) I’m getting an NPE in the CucumberUtils.afterStep() due to the KarateBackend returning a null for getVars(). AFAICT this is not a misconfiguration on my part, but rather a failure of the backend. Please advise.

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:
    * 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" }

SmokeTest.java

package apigee.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() {}

}

The 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.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
paulprogrammercommented, Aug 29, 2017

Verified working with 0.5.0.3

0reactions
ptrthomascommented, Aug 29, 2017

documentation was not being followed closing as invalid.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NPE on afterStep because KarateBackend.getVars() seems to ...
Given a basic feature file and task runner (below) I'm getting an NPE in the CucumberUtils.afterStep() due to the KarateBackend returning a ......
Read more >
NPE when trying to return null - java - Stack Overflow
The compiler picks float because Float can be coerced to float through ... Float toFloat(Float def, String str) { try { return str...
Read more >
Tired of Null Pointer Exceptions? Consider Using Java SE 8's ...
A common (bad) practice is to return the null reference to indicate the absence of a sound card. Unfortunately, this means the call...
Read more >
Null Pointer Exception In Java - GeeksforGeeks
NullPointerException is thrown when program attempts to use an object reference that has the null value.
Read more >
Avoiding the Null Pointer Exception With Optional in Java
The Null Pointer Exception has contributed the most bugs in production ... An empty Optional can be initialized by using Optional.empty() .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found