I am adding a system property in build.gradle like this - System.setProperty ‘env’,systemProperty ‘env’ ?: ‘dev’
Then trying to access in cucumber step def class using System.getProperty(“env”) but it’s throwing Null pointer exception, however I am successfully able to print System.getProperty(“env”) value in build.gradle and other test classes which are not step def files. Can anyone suggest something ?
The jvm which is executing the Gradle build is different from the jvm which is executing your cucumber tests. How are you executing cucumber (which task are you using?). There’s probably an option to set system properties on the test jvm. Eg something like
Thank you Lance, I wasn’t aware that JVM is different from Gradle and Cucumber, Now I understand why the system property value is printing in other classes but not in cucumber class.
I implemented the code as you suggested but still getting null pointer exception, my cucumber task is -
Because the JVM is different in Gradle and Cucumber, when I am running gradle cucumber there is no report in build. Report is only coming when running gradle test.I am able to generate cucumber-html-report using pretty plugin but Any idea how can I get Gradle report(index.html ) as well.