getgauge/gauge-js

How to use same table parameters used for a Gauge spec across multiple senarios?

Closed this issue · 1 comments

I have encountered into a problem where I have a simple gauge spec (say: Successful login with multiple user roles). This is just one spec. However what each user views (say various asserts) on the landing page after login depends on each user role. So one spec will have multiple scenarios . the spec has a data table like below.

Question: How to use same data table for multiple scenarios? (because my login function will be the same across all scenarios)

Problem: Would like to avoid hardcoding usernames across scenarios because password often changes and it will be a pain to update to every scenario.

Accessing the portal home using for various users.

id username
1 user_1
2 user_2

Verify user(s) performs a successfull login and assert text.

  • Goto portal page.
  • Write into textbox
  • Check "text" with text exists on landing page.

Scnario 2- Go through same login process and verify user_2 is able to view a specific button enabled.

sriv commented

If the flow is similar for every user role, but what each user role sees in various steps of the flow, consider bringing the expectations into the table, for ex:

|id|username|role|after login|
|--|--------|----|-----------|
|1|user_1|viewer|<selector for edit button disabled>|
...

This way your table can pass data + assert conditions to the scenarios.

From gauge's perspective, when a spec has a table, each scenario gets executed for every row in the table (if they use the table data, else just once).

However, if you still need scenarios to share table for other scenarios, consider externalizing the datatable as a csv and pass it as a parameter to a step.