Karate: Documentation error - Enviroment Switching for Gradle

Created on 29 Oct 2020  路  8Comments  路  Source: intuit/karate

In documentation https://github.com/intuit/karate#switching-the-environment

it configure gradlew enviroment variable using :

./gradlew test -Dkarate.env=e2e

but that dont work

image

The right way is :

command with -P

./gradlew test -Pkarate.env=e2e

and in build.gradle.tk (in my case) file :

systemProperties.set("karate.env", project.gradle.startParameter.projectProperties.get("env"))

i was 2 hours looking a workarround , if its only my case with kotlin, please make an annotation for some else

thanks!

documentation help wanted

Most helpful comment

Have you tried wrapping the -D options in quotes? I'm using the following and karate-config.js is picking up the -D options correctly.

gradle build -Plocal "-DfileLogLevel=info" "-DconsoleLogLevel=debug"

-Plocal is working as well, it's project specific and makes my build use local maven dependencies (I use it to make sure my Karate wrapper works before pushing to AzureGit).

edit to add:
My karate.log shows these two lines:
10:16:14.331 [Test worker] INFO com.intuit.karate - fileLogLevel system property was: info\n 10:16:14.332 [Test worker] INFO com.intuit.karate - consoleLogLevel system property was: debug

All 8 comments

@federicomarilungo ah gradle, my nemesis. I am not a gradle expert and am going to get someone I know to look at this and comment here, thanks for reporting. can you do me a favor and let me know what you think of https://github.com/intuit/karate/pull/1336 - is that ok or what

Have you tried wrapping the -D options in quotes? I'm using the following and karate-config.js is picking up the -D options correctly.

gradle build -Plocal "-DfileLogLevel=info" "-DconsoleLogLevel=debug"

-Plocal is working as well, it's project specific and makes my build use local maven dependencies (I use it to make sure my Karate wrapper works before pushing to AzureGit).

edit to add:
My karate.log shows these two lines:
10:16:14.331 [Test worker] INFO com.intuit.karate - fileLogLevel system property was: info\n 10:16:14.332 [Test worker] INFO com.intuit.karate - consoleLogLevel system property was: debug

And, my karate-config.js (I use a karate-base.js so config is short):
function fn() { var fileLogLevel = karate.properties['fileLogLevel']; var consoleLogLevel = karate.properties['consoleLogLevel']; karate.log('fileLogLevel system property was:', fileLogLevel); karate.log('consoleLogLevel system property was:', consoleLogLevel); }

EDIT: I HATE Github markdown!!

lots of thanks!

@federicomarilungo ah gradle, my nemesis. I am not a gradle expert and am going to get someone I know to look at this and comment here, thanks for reporting. can you do me a favor and let me know what you think of #1336 - is that ok or what

I believe is ok , but its an older gradle version
gradle in karate demo should be updated

im using gradle with kotlin now , so i cant test it easily

really thanks for answer. may be its works ok in older version of gradle

I'm using Gradle 6.2.2, which isn't 'THAT' old. We can't move passed that yet because our internal maven repository isn't publishing it's certs for TLS yet. :-/

ok, I'll see if anyone contributes a PR

I'm closing this - if anything needs to be changed in karate, I need a PR @federicomarilungo

Was this page helpful?
0 / 5 - 0 ratings