yaks icon indicating copy to clipboard operation
yaks copied to clipboard

citrus:env function results in NullPointerException

Open PhilipJonasFranz opened this issue 3 years ago • 1 comments

We require the use of custom properties via environment variables in our tests, so we used the citrus:env([ARG1], [ARG2]) function. However after extensive experimentation we simply could not get it to work as expected. The following snippet should reproduce the issue:

Feature: loadTest
  Scenario: Runs
    Given variable foo is "https://jsonplaceholder.typicode.com"
    Given URL: ${foo}
    When send GET /todos/1
    Then receive HTTP 200 OK
    
  Scenario: Fails
    Given variable foo is "citrus:env('TESTENV','https://jsonplaceholder.typicode.com')"
    Given URL: ${foo}
    When send GET /todos/1
    Then receive HTTP 200 OK

with the command yaks run -e TESTENV=https://web.de/ -n yakstesting test.feature to run it. It results in the following error:

java.lang.NullPointerException
at com.consol.citrus.functions.core.EnvironmentPropertyFunction.execute(EnvironmentPropertyFunction.java:58)
at com.consol.citrus.functions.FunctionUtils.resolveFunction(FunctionUtils.java:143)
at com.consol.citrus.functions.FunctionUtils.replaceFunctionsInString(FunctionUtils.java:96)
at com.consol.citrus.context.TestContext.replaceDynamicContentInString(TestContext.java:406)

If this is a problem on our end, could you please provide an adjusted snippet that is able to correctly retrieve environment variables passed via --env?

Thank you in advance!

PhilipJonasFranz avatar Sep 08 '22 12:09 PhilipJonasFranz

This is a bug in the underlying Citrus library. Please refer to this issue that has been raised in Citrus https://github.com/citrusframework/citrus/issues/894

christophd avatar Sep 28 '22 08:09 christophd