question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ability to write variables in test file

See original GitHub issue

Looking forward for something like where users are able to declare their own variables inside tavern file. I know there is a way to use !include and declare but I want it to be specific to this test case file.

test_name: Sample Test Name
variables:
  common_url: "https://sample.com/{group_endpoint}"

stages:
  - name: List specific group with id
    request:
        url: "{common_url}/id/abc1"
        method: GET
    response:
        status_code: 200

  - name: List specific group with id2
    request:
        url: "{common_url}/id/abc2"
        method: GET
    response:
        status_code: 200

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ashishpatel1992commented, Jan 10, 2022

What I mean is I have a common.yaml file which contains some variables like domain name and port number. But now I want to add more variable specific to the test only and use some variables from common.yaml to build new variables specific for the current test file.

Ah sorry, I didn’t realise you meant inside one file and not just in one test.

Each test in Tavern is a separate YAML document and are all basically treated as separate files so you can’t do something like that. Do you want something like:

variables:
      list_all_users: "https://{domain_name}:{port}/users/"
      select_user: "https://{domain_name}:{port}/users/55"
---
test_name: test 1
stages:
	...
---
test_name: test 2
stages:
	...

?

1reaction
michaelboultoncommented, Jan 8, 2022

Ah sorry, I didn’t realise you meant inside one file and not just in one test.

Each test in Tavern is a separate YAML document and are all basically treated as separate files so you can’t do something like that. Do you want something like:

variables:
      list_all_users: "https://{domain_name}:{port}/users/"
      select_user: "https://{domain_name}:{port}/users/55"
---
test_name: test 1
stages:
	...
---
test_name: test 2
stages:
	...

?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to write any variable created in a test to the jasmine ...
I have jasmine-reporters set up and working, and writing to an output.xml file. How do I get any variables I create in my...
Read more >
Test your skills: variables - Learn web development | MDN
The aim of this skill test is to assess whether you've understood our Storing the information you need — Variables article.
Read more >
How to Write Test Cases: The Ultimate Guide with Examples
Tutorial #3: Writing Test Cases from SRS Document ... Tutorial #24: Boundary value analysis and Equivalence partitioning ...
Read more >
Unit Tests, How to Write Testable Code, and Why It Matters
In this article, I will show that unit testing itself is quite easy; the real problems that complicate unit testing, and introduce expensive...
Read more >
TestComplete 301: Variables & Variable Creation - YouTube
This class will teach you all about variables in TestComplete. Download a free trial of TestComplete here: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found