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.

How to call on_start before each testcase, like setup in unittest?

See original GitHub issue

Feature request

Setup method like unittest

Expected behavior

Method on_start only run once, but my testcase require different parameter recieved from an HTTP response.

If I get this variable with on_start, then only first test can pass; and if I call the get_parameter method in testcase, it will makes testresult inaccurate for the time waiting for response.

Actual behavior

Is there any method like setup with unittest(I didn’t find in document), or any suggests that can solve this scene?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
cyberwcommented, Jul 6, 2022

There’s no built in way to do that, but you can override the run task method, as done here for example https://github.com/SvenskaSpel/locust-plugins/blob/bf4097eb3a04580de886b5b138151a6b0d21660e/locust_plugins/__init__.py#L209

1reaction
cgoldbergcommented, Apr 23, 2018

similar feature is already implemented and the code has landed in master. see: https://docs.locust.io/en/latest/writing-a-locustfile.html#setups-teardowns-on-start-and-on-stop

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - How to unit test a .NET middleware that uses Response ...
I am not finding a way to unit test this middleware, as it uses the OnStarting callback and I can't imagine how to...
Read more >
Android — How to test a Service - Medium
Recently i worked on a project where i had to test a service, and id like to share with you all how to...
Read more >
How to Write Effective Unit Tests in Java - Twilio
Create a new Java class called Validator.java inside the ... There will remain only a single method call on this class for each...
Read more >
Unit Testing with Robolectric | CodePath Android Cliffnotes
(Mac and Linux users only) => There is a known issue that needs to be addressed so that tests can be located properly....
Read more >
Learning State & Shared Flows with Unit Tests
We send an item to a state flow by calling the emit method on the flow. Here is a unit test where we...
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