2
\$\begingroup\$

I am new to BDD/Specflow and was wondering if I could get some feedback on my definitions

Here is what I have for a simple customer creation feature/command:

Scenario: Creating a customer with an account number that already is used
 Given a customer already exists with the account number CUSTOMER001
 When I try to create a new customer with same account number
 Then the system should say that an account number must be unique
Scenario: Creating a customer with a name that already is used
 Given a customer already exists with the name Customer01
 When I try to create a new customer with same name
 Then the system should say that a customer name must be unique
Scenario: Creating a customer with a name that already is used (lowercase)
 Given a customer already exists with the name Customer01
 When I try to create a new customer with name customer01
 Then the system should say that a customer name must be unique
Scenario: Creating a customer
 Given no customer exists with the account number CUSTOMER001
 And no customer exists with the name Customer01
 When I try to create a new customer the account number CUSTOMER001 and name Customer01
 Then that customer should be created

I have a few questions:

  • For the last test (the success test) where a customer is created, the when seems overloaded, because I am specifying both parameters. is this fine?
  • Because business code usually is guarded, I have the failure tests then a successful one. The successful one seems it might be overloaded as it says the reverse of each failure criteria, is this ok (e.g. no customer exists with number, no customer exists with name, etc..) Should I say instead something else? No customer exists would work, but that isnt going to ever be a real example

Any general feedback would be massively helpful as I am really new to this

Greg Burghardt
5,96914 silver badges26 bronze badges
asked Mar 25, 2022 at 22:26
\$\endgroup\$
1
  • \$\begingroup\$ I never thought about gherkin being a candidate for a code review. I like it, though. I changed the title to include what this code does (defines the behavior around creating customers). \$\endgroup\$ Commented Mar 29, 2022 at 0:23

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.