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.

Calling karate.abort() in the Background gives a Nullpointer-exception

See original GitHub issue

Hi,

Because I don’t want some featuers running on some environments I saw your comment here: https://stackoverflow.com/questions/54308190/karate-how-to-run-a-specific-scenario-only-in-one-environment

So I created this feature-file:

Feature: karate-abort

  Background:
    * print 'Before the eval'
    * eval if (karate.env == 'accp') karate.abort()
    * print 'After the eval'

  Scenario: test interaction
    * print 'In the scenario'

I need to use karate.abort() in the Background, because we’re generating tokens etc. before each scenario which can’t be done on this environment.

But this leads this Nullpointer exception:

java.lang.NullPointerException at com.intuit.karate.core.Step.getDebugInfo(Step.java:46) at com.intuit.karate.core.ScenarioExecutionUnit.execute(ScenarioExecutionUnit.java:202) at com.intuit.karate.core.ScenarioExecutionUnit.run(ScenarioExecutionUnit.java:239) at com.intuit.karate.core.FeatureExecutionUnit.run(FeatureExecutionUnit.java:164) at com.intuit.karate.core.FeatureExecutionUnit.run(FeatureExecutionUnit.java:73) at com.intuit.karate.junit4.Karate.runChild(Karate.java:125) at com.intuit.karate.junit4.Karate.runChild(Karate.java:56) 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.RunAfters.evaluate(RunAfters.java:27) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at com.intuit.karate.junit4.Karate.run(Karate.java:133) 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)

It looks like that the Nullpointer is only in the getDebugInfo()-method. Is there a workaround to have this behavior without the Nullpointer?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
ptrthomascommented, Dec 10, 2019

@gerben86 please use 0.9.5.RC5 I consider it production-ready: https://twitter.com/KarateDSL/status/1203704874619166720

0reactions
ptrthomascommented, Feb 16, 2020

released 0.9.5

Read more comments on GitHub >

github_iconTop Results From Across the Web

Calling karate.abort() in the Background gives a Nullpointer ...
I need to use karate.abort() in the Background, because we're generating tokens etc. before each scenario which can't be done on this ...
Read more >
Getting java.lang.nullpointer exception while calling feature file
I have various techniques and methods which are provided karate official blog but still the error is same. Feature: Quote generator Background: ...
Read more >
Bash Concatenate Strings - Morioh
String concatenation is just a fancy programming word for joining strings together by appending one string to the end of another string.
Read more >
Spring 5.0.7 - Переклад українською - Арсеній Чеботарьов
However, if the same method name is configured - for example, init() for an initialization method - for more than one of these...
Read more >
Learn Java 12 Programming.pdf - Open Directory Data Archive
Chapter 12, Java GUI Programming, provides an overview of Java GUI ... Since JDK provides its own operating environment, it is called a...
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