Skip to content

Latest commit

 

History

History
42 lines (28 loc) · 1.01 KB

VDR305.md

File metadata and controls

42 lines (28 loc) · 1.01 KB

VDR305. Scenario should have a "then" step

The Vedro framework categorizes steps into three types:

  • “given” - arrange steps, preparing data,
  • “when” - the main act,
  • “then”, “and” and “but” - asserts

Not asserting anything scenario considered to be having a mistake

❌ Anti-pattern

class Scenario(vedro.Scenario):
    subject = "login"

    def given_user_data(self):
        self.user = fake(NewUserSchema)

    def when_user_logins(self):
        self.response = httpx.post(f"{API_URL}/auth/login", json=self.user)

✅ Best practice

class Scenario(vedro.Scenario):
    subject = "login"

    def given_user_data(self):
        self.user = fake(NewUserSchema)

    def when_user_logins(self):
        self.response = httpx.post(f"{API_URL}/auth/login", json=self.user)

    def then_it_should_return_success_status_code(self):
        assert self.response.status_code == 200

Additional links