java.lang.NoSuchFieldException: modifiers on jdk12.0.2
QAF Version
Note: only the latest version is supported 3.0.0-RC3
Steps To Reproduce
1.maven:`<dependency>
<groupId>com.qmetry</groupId>
<artifactId>qaf-cucumber</artifactId>
<version>3.0.0-RC3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.qmetry</groupId>
<artifactId>qaf</artifactId>
<version>3.0.0-RC3</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-multipart</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-apache-client</artifactId>
</exclusion>
</exclusions>
</dependency>`
2.Cucumber-jvm cukerunner`@CucumberOptions(plugin = { "pretty", "html:build/reports/demo-cucumber", "json:build/cucumber/demo-cucumber.json",
"io.qameta.allure.cucumber5jvm.AllureCucumber5Jvm",
"com.qmetry.qaf.automation.cucumber.QAFCucumberPlugin" }`
3.run on jdk8 no thing wrong
4.run on jdk12.0.2 there is a exceprion
5.Can we change this part:`Field modifiersField = Field.class.getDeclaredField("modifiers");`
Expected behavior
Actual behavior
16:07:15 Added "QAFMethodSelector"
16:07:15 java.lang.NoSuchFieldException: modifiers
16:07:15 at java.base/java.lang.Class.getDeclaredField(Class.java:2416)
16:07:15 at com.qmetry.qaf.automation.util.ClassUtil.setField(ClassUtil.java:599)
16:07:15 at com.qmetry.qaf.automation.testng.pro.QAFExecutionListener.
Is the issue reproducible on runner?
- [ ] QAS
- [x] Maven
- [ ] Gradle
- [ ] Ant
- [ ] Eclipse
Test case sample
Please, share the test case (as small as possible) which shows the issue
Is it specific to jdk version?
Is it specific to jdk version?
higher than jdk12
Thanks for reporting. As we have to support java minimum version 8 because many of enterprises using java 8 we can't immediately provide fix for this issue.
By the way when you are using qaf-cucumber, TestNG is not required. So you can use plain cucumber runner or Junit runner and in that case you should not see above error.
Ok, I understand. However I have tried to exclusive testng from qaf in maven, but it does have some dependence make me can not use the plugin "com.qmetry.qaf.automation.cucumber.QAFCucumberPlugin". Is there any solution?
This issue is version compatibility issue rather than a bug, but to get more attention in future, marked as bug.
it's not related to excluding dependency but using runner. It looks like that you are using TestNG runner with cucumber. So instead of that you can use Junit runner and run as Junit or use cucumber runner and run as Java.
Here are few examples:
I'm using cucumber-junit The runner is: @CucumberOptions(plugin = { "pretty", "html:build/reports/demo-cucumber", "json:build/cucumber/demo-cucumber.json", "io.qameta.allure.cucumber5jvm.AllureCucumber5Jvm", "com.qmetry.qaf.automation.cucumber.QAFCucumberPlugin" } It seems nothing about testng but it will touch testng
You need to fix your POM to run Junit instead of TesNG. From the exception i can see that surefire plugin is running as TestNG
16:07:15 at org.testng.TestNG.run(TestNG.java:1089) 16:07:15 at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:135) 16:07:15 at
You need to fix your POM to run Junit instead of TesNG. From the exception i can see that surefire plugin is running as TestNG
16:07:15 at org.testng.TestNG.run(TestNG.java:1089) 16:07:15 at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:135) 16:07:15 at
Ok , thank you, I will check it
You need to fix your POM to run Junit instead of TesNG. From the exception i can see that surefire plugin is running as TestNG
16:07:15 at org.testng.TestNG.run(TestNG.java:1089) 16:07:15 at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:135) 16:07:15 at
Hi
I just found out that I run my cucumber in maven in
-Dtest=com.geetest.deepknow.runner.CukeTest test -Dcucumber.options="--tags ${tags} "
It will run cucumber-junit but also surefire-testng.
It will not run testng if I just use the IDE junit runner to the project, it will pass.
Any solution can I use to run the project in maven test and not to run testng?
You need to fix your POM to run Junit instead of TesNG. From the exception i can see that surefire plugin is running as TestNG
16:07:15 at org.testng.TestNG.run(TestNG.java:1089) 16:07:15 at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:135) 16:07:15 at
And I finally run without testng, However the log
14:24:13 java.lang.NoSuchFieldException: modifiers
14:24:13 at java.base/java.lang.Class.getDeclaredField(Class.java:2416)
14:24:13 at com.qmetry.qaf.automation.util.ClassUtil.setField(ClassUtil.java:599)
14:24:13 at com.qmetry.qaf.automation.cucumber.bdd2.parser.Bdd2Compiler.getExamples(Bdd2Compiler.java:200)
14:24:13 at com.qmetry.qaf.automation.cucumber.bdd2.parser.Bdd2Compiler.compileScenarioOutline(Bdd2Compiler.java:126)
14:24:13 at com.qmetry.qaf.automation.cucumber.bdd2.parser.Bdd2Compiler.compile(Bdd2Compiler.java:96)
14:24:13 at com.qmetry.qaf.automation.cucumber.bdd2.parser.BDD2FeatureParser.compilePickles(BDD2FeatureParser.java:57)
14:24:13 at com.qmetry.qaf.automation.cucumber.bdd2.parser.BDD2FeatureParser.parseBDD2(BDD2FeatureParser.java:41)
14:24:13 at com.qmetry.qaf.automation.cucumber.bdd2.parser.BDD2FeatureParser.parse(BDD2FeatureParser.java:69)
14:24:13 at io.cucumber.core.feature.FeatureParser.parseResource(FeatureParser.java:44)
14:24:13 at java.base/java.util.function.BiFunction.lambda$andThen$0(BiFunction.java:70)
14:24:13 at io.cucumber.core.resource.ResourceScanner.lambda$processResource$2(ResourceScanner.java:126)
14:24:13 at io.cucumber.core.resource.PathScanner$ResourceFileVisitor.visitFile(PathScanner.java:67)
14:24:13 at io.cucumber.core.resource.PathScanner$ResourceFileVisitor.visitFile(PathScanner.java:52)
14:24:13 at java.base/java.nio.file.Files.walkFileTree(Files.java:2801)
14:24:13 at java.base/java.nio.file.Files.walkFileTree(Files.java:2873)
14:24:13 at io.cucumber.core.resource.PathScanner.findResourcesForPath(PathScanner.java:46)
14:24:13 at io.cucumber.core.resource.PathScanner.findResourcesForUri(PathScanner.java:26)
14:24:13 at io.cucumber.core.resource.ResourceScanner.findResourcesForUri(ResourceScanner.java:109)
14:24:13 at io.cucumber.core.resource.ResourceScanner.scanForResourcesUri(ResourceScanner.java:86)
14:24:13 at io.cucumber.core.runtime.FeaturePathFeatureSupplier.loadFeatures(FeaturePathFeatureSupplier.java:61)
14:24:13 at io.cucumber.core.runtime.FeaturePathFeatureSupplier.get(FeaturePathFeatureSupplier.java:45)
14:24:13 at io.cucumber.junit.Cucumber.
is it blocking (exit without executing tests) or showing error and continues to run the test?
is it blocking (exit without executing tests) or showing error and continues to run the test?
I'm using cucumber-jvm. It is blocking in one Scenario then run another Scenario then blocking.
If my understanding is correct, all scenarios get executed. If so it means not blocking. You can ignore console log as long as scenario get executed and report has correct results.
If my understanding is correct, all scenarios get executed. If so it means not blocking. You can ignore console log as long as scenario get executed and report has correct results.
all scenarios get executed but it will throw the exception in the beginning and my test steps will not execute.
Will you try 3.0.0-SNAPSHOT? You will required to add snapshots repository to your pom.
<repository>
<id>nexus-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
OK, thanks, I will try it
3.0.0-SNAPSHOT
I change qaf-cucumber to 3.0.0-SNAPSHOT, there is an exception in the beginning. Then all scenarios get executed
14:06:17 java.lang.NoSuchFieldException: modifiers
14:06:17 at java.base/java.lang.Class.getDeclaredField(Class.java:2416)
14:06:17 at com.qmetry.qaf.automation.util.ClassUtil.setField(ClassUtil.java:599)
14:06:17 at com.qmetry.qaf.automation.cucumber.bdd2.parser.Bdd2Compiler.getExamples(Bdd2Compiler.java:200)
14:06:17 at com.qmetry.qaf.automation.cucumber.bdd2.parser.Bdd2Compiler.compileScenarioOutline(Bdd2Compiler.java:126)
14:06:17 at com.qmetry.qaf.automation.cucumber.bdd2.parser.Bdd2Compiler.compile(Bdd2Compiler.java:96)
14:06:17 at com.qmetry.qaf.automation.cucumber.bdd2.parser.BDD2FeatureParser.compilePickles(BDD2FeatureParser.java:57)
14:06:17 at com.qmetry.qaf.automation.cucumber.bdd2.parser.BDD2FeatureParser.parseBDD2(BDD2FeatureParser.java:41)
14:06:17 at com.qmetry.qaf.automation.cucumber.bdd2.parser.BDD2FeatureParser.parse(BDD2FeatureParser.java:69)
14:06:17 at io.cucumber.core.feature.FeatureParser.parseResource(FeatureParser.java:44)
14:06:17 at java.base/java.util.function.BiFunction.lambda$andThen$0(BiFunction.java:70)
14:06:17 at io.cucumber.core.resource.ResourceScanner.lambda$processResource$2(ResourceScanner.java:126)
14:06:17 at io.cucumber.core.resource.PathScanner$ResourceFileVisitor.visitFile(PathScanner.java:67)
14:06:17 at io.cucumber.core.resource.PathScanner$ResourceFileVisitor.visitFile(PathScanner.java:52)
14:06:17 at java.base/java.nio.file.Files.walkFileTree(Files.java:2801)
14:06:17 at java.base/java.nio.file.Files.walkFileTree(Files.java:2873)
14:06:17 at io.cucumber.core.resource.PathScanner.findResourcesForPath(PathScanner.java:46)
14:06:17 at io.cucumber.core.resource.PathScanner.findResourcesForUri(PathScanner.java:26)
14:06:17 at io.cucumber.core.resource.ResourceScanner.findResourcesForUri(ResourceScanner.java:109)
14:06:17 at io.cucumber.core.resource.ResourceScanner.scanForResourcesUri(ResourceScanner.java:86)
14:06:17 at io.cucumber.core.runtime.FeaturePathFeatureSupplier.loadFeatures(FeaturePathFeatureSupplier.java:61)
14:06:17 at io.cucumber.core.runtime.FeaturePathFeatureSupplier.get(FeaturePathFeatureSupplier.java:45)
14:06:17 at io.cucumber.junit.Cucumber.
You can ignore console log as long as your scenarios get executed, working as expected and reports correct pass/fail results in qaf dashboard. Keep in mind that cucumber/junit result may be incorrect for verification failure but qaf dashboard results should be correct.
You can ignore console log as long as your scenarios get executed, working as expected and reports correct pass/fail results in qaf dashboard. Keep in mind that cucumber/junit result may be incorrect for verification failure but qaf dashboard results should be correct.
OK, I think it works. qaf-cucumebr-3.0.0-SNAPSHOT will release soon?