从 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"
我的测试套件在使用 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);
}
现在当我执行这个套件时,测试正在正确执行。但是在完成所有功能文件的测试执行后,它会为
行抛出错误
Results stats = 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.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.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access[=15=]0(ParentRunner.java:58)
at org.junit.runners.ParentRunner.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 中的某些内容失败
感谢提示 - 这确实是时间线报告代码中的错误。
问题参考:https://github.com/intuit/karate/issues/1085
所以你要等下个版本,不然应该很快就会出RC版,大家可以试试
我的测试套件在使用 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);
}
现在当我执行这个套件时,测试正在正确执行。但是在完成所有功能文件的测试执行后,它会为
行抛出错误Results stats = 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.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.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access[=15=]0(ParentRunner.java:58)
at org.junit.runners.ParentRunner.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 中的某些内容失败
感谢提示 - 这确实是时间线报告代码中的错误。
问题参考:https://github.com/intuit/karate/issues/1085
所以你要等下个版本,不然应该很快就会出RC版,大家可以试试