从 0.9.2 更新到 0.9.5 后出现错误“java.lang.IllegalArgumentException: Illegal group reference”
Posted
技术标签:
【中文标题】从 0.9.2 更新到 0.9.5 后出现错误“java.lang.IllegalArgumentException: Illegal group reference”【英文标题】:After updating from 0.9.2 to 0.9.5 getting the error "java.lang.IllegalArgumentException: Illegal group reference" 【发布时间】:2020-07-01 11:27:32 【问题描述】:在使用 0.9.2 版本之前,我的测试套件运行良好。
我有一个测试运行器,其中包含 KarateOptions 来指定要执行的功能文件
@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",
)
为此的测试运行器使用的是黄瓜运行器,
@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);
我尝试将框架升级到 0.9.5 并修改了运行器,就像它在最新文档中提到的那样,
@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);
现在,当我执行此套件时,测试正在正确执行。但是在所有功能文件的测试执行完成后,它正在为该行抛出错误
结果统计 = Runner.parallel(getClass(), 1, karateOutputPath);
出现以下 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)
打电话给跑步者时我错过了什么?如何解决这个问题?
当我尝试为失败的步骤添加异常处理程序时,我得到以下错误日志,
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)
saveTimelineHtml 中的某些内容失败
【问题讨论】:
【参考方案1】:感谢您的提示 - 这确实是时间线报告代码中的一个错误。
问题参考:https://github.com/intuit/karate/issues/1085
所以你需要等待下一个版本,或者应该很快会有一个RC版本,这样你就可以试用了。
【讨论】:
非常感谢,急切等待修复:)以上是关于从 0.9.2 更新到 0.9.5 后出现错误“java.lang.IllegalArgumentException: Illegal group reference”的主要内容,如果未能解决你的问题,请参考以下文章
从 Angular 9 更新到 Angular 10 后,`SCSS` 不起作用