With the new release (2.40), Locust supports pytest style scenarios. Simply create a regular pytest, using one of the fixtures exposed by Locust:
```
def test_stuff(session):
if not session.base_url:
session.base_url = "http://127.0.0.1:3000"
resp = session.get("/api", name="GET /api")
resp.raise_for_status()
```
Then you can run the file using
`locust -f test_thing.py`
or (to just run it once, for functional validation)
`pytest test_thing.py`
Complete example here: <https://github.com/locustio/locust/blob/master/examples/test_pytest.py>
With the new release (2.40), Locust supports pytest style scenarios. Simply create a regular pytest, using one of the fixtures exposed by Locust:
```
def test_stuff(session):
resp = session.get("/")
resp.raise_for_status()
resp = session.get("/page/about")
resp.raise_for_status()
```
Then you can run the file using
`locust -H http://localhost:5000`
or (to just run it once, for functional validation)
`pytest -H http://localhost:5000 locustfile.py`
Complete example here: https://github.com/locustio/locust/blob/master/examples/test_pytest.py