ovh / venom

🐍 Manage and run your integration tests with efficiency - Venom run executors (script, HTTP Request, web, imap, etc... ) and assertions
Apache License 2.0
1.04k stars 142 forks source link

Setting vars value with result of a step does not seem to evaluate #774

Open 1am opened 7 months ago

1am commented 7 months ago

Hello, I'm using Version v1.1.0 and needed to use the feature documented in vars.yml test. It wasn't working for me in my test so I coped the test testcase and it also fails with the following

$ venom run vars.yml -vvvv
      [trac] writing venom.12.log
 • Variables testsuite (vars.yml)
    • CreateService
        • exec PASS
          [trac] writing vars.CreateService.step.0.0.dump.json
    • WriteServiceIdForNextTestSuites
        • exec PASS
          [trac] writing vars.WriteServiceIdForNextTestSuites.step.0.0.dump.json
    • echo_myvar
        • exec FAIL
          Testcase "echo_myvar", step #0-0: Assertion "result.systemout ShouldContainSubstring foo" failed. expected '{{.myvar}}' to contain 'foo' but it wasn't (vars.yml:34)
          [info] {{.myvar}} (vars.yml:30)
          [trac] writing vars.echo_myvar.step.0.0.dump.json
final status: FAIL

What am I doing wrong and is there a way to work around this? I need to pass an ID from one step into bodyfile of a subsequent step which posts a JSON file which includes ID. I hoped to use the vars.yml test mechanism for this.

FloRichardAloeCorp commented 7 months ago

The feature works but the example seems broken. Can you share your test to see what you are doing wrong ?

1am commented 7 months ago

My example was somewhat more specific version of vars.yml but even if it would work it would help. In the end what I was aiming at (out of scope of this issue I guess) was similar to tests/http_post_bodyfile.yaml in which my template file placeholders would be populated with values set after first step of the test.

ivan-velasco commented 7 months ago

@1am Have you tried version https://github.com/ovh/venom/releases/tag/v1.2.0-beta.4

New changes to vars

1am commented 7 months ago

Just tried updating to 1.2.0-beta.4 and the result is the same: Testcase "echo_myvar", step #0-0: Assertion "result.systemout ShouldContainSubstring foo" failed. expected '{{.myvar}}' to contain 'foo' but it wasn't (vars.yml:34) when running vars.yml

yesnault commented 6 months ago

Hi @1am , can you provide a full reproducer please?

1am commented 6 months ago

Hello @yesnault The full reproducer was an exact copy of vars.yml without any changes.