After updating from 0.9.2 to 0.9.5 getting the error “java.lang.IllegalArgumentException: Illegal group reference”

百般思念 提交于 2020-05-13 07:48:45

问题


My test suite was working fine until it was using the version 0.9.2.

I have a test runner with KarateOptions in it to specify the feature files that are to be executed

@KarateOptions(tags = {"~@ignore"},
    features = {
            "src/test/java/com/pro/api/tests/features/beforesuitescenarios/feature1.feature",
             "src/test/java/com/pro/api/tests/features/customerscenarios/feature2.feature",
            "src/test/java/com/pro/api/tests/features/servicerequestscenarios/feature3.feature",
            "src/test/java/com/pro/api/tests/features/invoicescenarios/feature4.feature",

    })

And the test runner for this was using cucumber runner,

  @Test
public void testAllFeatures() throws Exception { 
    String karateOutputPath = "target/surefire-reports";
    KarateStats stats = CucumberRunner.parallel(getClass(), 1, karateOutputPath);
    generateReport(karateOutputPath);
    assertTrue("There are scenario failures", stats.getFailCount() == 0);
}

I tried upgrading the framework to 0.9.5 and modified the runner like it's mentioned in the latest docs,

@Test
public void testAllFeatures() throws Exception {

    String karateOutputPath = "target/surefire-reports";
    Results stats = Runner.parallel(getClass(), 1, karateOutputPath);
    generateReport(karateOutputPath);
    assertTrue("There are scenario failures", stats.getFailCount() == 0);
}

Now when I execute this suite, The tests are getting executed properly. But after the test execution of all the feature files are completed, It is throwing an error for the line

Results stats = Runner.parallel(getClass(), 1, karateOutputPath);

With the following IllegalArgumentException,

[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1,295.291 s <<< 
FAILURE! - in com.pro.api.tests.features.TestRunner
[ERROR] testAllFeatures(com.pro.api.tests.features.TestRunner)  Time elapsed: 1,295.22 s  
 <<< ERROR!
java.lang.IllegalArgumentException: Illegal group reference
at com.pro.api.tests.features.TestRunner.testAllFeatures(TestRunner.java:55)

What am I missing while calling the runner ? How to fix this issue ?

Further when I tried to add exception handler for the failing step, I got the following error log,

java.lang.IllegalArgumentException: Illegal group reference
at java.base/java.util.regex.Matcher.appendExpandedReplacement(Matcher.java:1068)
at java.base/java.util.regex.Matcher.appendReplacement(Matcher.java:998)
at java.base/java.util.regex.Matcher.replaceFirst(Matcher.java:1408)
at java.base/java.lang.String.replaceFirst(String.java:2081)
at com.intuit.karate.core.Engine.saveTimelineHtml(Engine.java:500)
at com.intuit.karate.Runner.parallel(Runner.java:357)
at com.intuit.karate.Runner$Builder.parallel(Runner.java:181)
at com.pro.api.tests.features.TestRunner.testAllFeatures(TestRunner.java:56)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
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 org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1,181.97 s <<< FAILURE! - in com.pro.api.tests.features.TestRunner
[ERROR] testAllFeatures(com.pro.api.tests.features.TestRunner)  Time elapsed: 1,181.905 s  <<< ERROR!
java.lang.NullPointerException
    at com.pro.api.tests.features.TestRunner.testAllFeatures(TestRunner.java:61)

Something in saveTimelineHtml is failing


回答1:


Thanks for the hint - this is indeed a bug in the timeline reporting code.

Issue reference: https://github.com/intuit/karate/issues/1085

So you need to wait for the next version, or there should be an RC version pretty soon so that you can try it out.



来源:https://stackoverflow.com/questions/60772244/after-updating-from-0-9-2-to-0-9-5-getting-the-error-java-lang-illegalargumente

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!