Run `beforeScenario` only once before a scenario
See original GitHub issueI thought that I can use the beforeScenario
to call my auth service to get an access token and use that for each call to the service I’m load testing. However, my auth
function is called before each endpoint call. That is suboptimal because I don’t want load test my auth service at the same time I load test all my other services.
Code example:
scenarios:
- name: "Endpoint returns 200"
beforeScenario: "auth"
flow:
- get:
url: "/api/v1/endpoint"
expect:
- statusCode: 200
- contentType: json
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:14 (1 by maintainers)
Top Results From Across the Web
Specflow beforeScenario in base class called multiple times ...
When I want a BeforeScenario to run only once per test run I will put it into its own "hooks" class. Since both...
Read more >Hooks - SpecFlow's documentation
When running tests in multiple threads with SpecFlow+ Runner, Before and After hooks such as BeforeTestRun and AfterTestRun are executed once for each ......
Read more >run background before scenario outline, but just one time
If I have a Background section and a Scenario Outline, the Background runs once before each example in the scenario outline. Is there...
Read more >Before Scenario hook in specflow running twice multiple times
Join this channel to get access to perks:https://www.youtube.com/channel/UCoSpmr2KNOxjwE_B9ynUmig/joinMy GearCamera ...
Read more >Cucumber Hooks - Baeldung
Methods annotated with @Before will execute before every scenario. ... initialization() executes first, and beforeScenario() executes second ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
beforeScenario
is indeed meant to be run before each scenario execution (by each virtual user).There is a way to run a call just once via a
before
section at the top level of the test definition. The contents of the section can be an arbitrary scenario, but any variables captured by that scenario will be available to all virtual users.Quick example:
Do you know if is there an “after” instruction too? I need to delete a parent element that I created in the “before” section. I looked through the documentation but I see nothing
I added this at the root level but seems to do nothing: