citrusframework / yaks

YAKS is a platform to enable Cloud Native BDD testing on Kubernetes
Apache License 2.0
83 stars 27 forks source link

citrus:env function results in NullPointerException #436

Closed PhilipJonasFranz closed 1 year ago

PhilipJonasFranz commented 1 year ago

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!

christophd commented 1 year ago

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