Behavior Driven Development Flashcards

1
Q

Behavior

A
  • How a product or feature operates. Ex.:
  • logging into a webpage
  • clicking links in nav bar
  • submitting forms
  • making successful service calls
  • receiving expected errors
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is BDD?

A
  • a test-centric software development process that grew out of Test-Driven Development
  • has been around since the mid-2000s
  • behaviors become the team’s focus
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

BDD is a refinement of the Agile process, not an overhaul.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Advantages of BDD (part 1):

A
  • Inclusion: anyone can write BDD scenarios
  • Clarity: focus on expected behavior of product
  • Streamlining: requirements = acceptance criteria = test cases. Expedites automation.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Advantages of BDD (part 2):

A
  • Shift-Left: testing early in the development process, results in fewer bugs later
  • Artifacts: scenarios form a collection of test cases. Any tests not automated can be added to a known automation backlog.
  • Automation: BDD frameworks make it easy to turn scenarios into automated tests
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Advantages of BDD (part 3):

A
  • Test Driven: most BDD frameworks can run scenarios to fail until the feature is implemented
  • Code Reuse: “Given-When-Then” steps can be reused between scenarios
  • Parametrization: steps can be parametrized
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Advantages of BDD (part 4):

A
  • Variation: scenario outlines make it easy to run the same scenario with different combinations of inputs
  • Momentum: scenarios become easier and faster to write and automate as more step definitions are added
  • Adaptability: scenarios are easy to update as the product changes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What types of tests are BDD best suited for?

A
  • Higher level, functional, black box tests

- E.g., testing APIs and web UIs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What types of tests is BDD NOT well-suited for?

A
  • Overkill for unit tests

- Not good for performance tests, which rely on metrics instead of pass/fail results

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Gherkin

A

domain-specific language for writing BDD scenarios whose language standard is maintained by Cucumber (a prevalent BDD automation framework)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Gherkin scenario structure:

A

Given-When-Then

Given some initial state, when an action is taken, then verify an outcome

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Gherkin Features

A
  • has a title and description - only used for documentation purposes
  • associated with user stories
  • may have one Background section
  • may have multiple associated scenarios and scenario outlines
  • should only have one Feature per feature file
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Gherkin Scenarios

A
  • each scenario is essentially a test case
  • each Given/When/Then line is called a step
  • steps MUST appear in the Given/When/Then order
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How to write good steps:

A

Good steps are declarative - states what should happen at a high-level

Not imperative - shouldn’t focus on direct, low-level instructions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

In a scenario, each type of step is optional.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

In a scenario, step order matters.

A

True

17
Q

Scenarios are dependent on each other to run.

A

False. Each scenario runs independently.

18
Q

Additional steps that can be added to Given, When, or Then:

A
  • And: used instead of repeating G/W/T

- But: functions the same as And, but might be easier to read. Interchangeable with And.

19
Q

Gherkin: And

A
  • used instead of repeating G/W/T
  • example: Given-Given-When-Then = Given-And-When-Then
  • associated with the immediately preceding step
  • order matters
20
Q

Gherkin: Background

A
  • a section of Given and And statements to run before each scenario
  • does not have a title or description
  • only one Background for each Feature section
21
Q

How do you denote parameter names in Gherkin?

A

< >

22
Q

Scenario outlines may have multiple Examples tables.

A

True

23
Q

What are Examples?

A
  • a section to provide a table of parameter values for a Scenario Outline
  • each table row represents a combination of values to test together
  • may have any positive number of rows
24
Q

Gherkin Keywords: | (pipe character)

A
  • table delimeter used for Examples tables and step tables

- use the escape sequence “|” to use pipe characters as text within a column

25
Q

Gherkin Keywords: “””

A
  • doc string delimiter for passing large text into a step

- doc strings may be multi-line

26
Q

Gherkin Keywords: @

A
  • prefix for a tag: @
  • tags may be placed before Feature or Scenario sections
  • tags are used to filter scenarios
27
Q

Gherkin Keywords: #

A
  • prefix for a comment line

- comments are not read by the Gherkin parser

28
Q

How should you phrase Gherkin steps?

A

Use third person point of view in present tense, and write in complete sentences

29
Q

Gherkin contains an Or step.

A

False. Use Scenario Outlines to cover multiple variations of the same behavior.

30
Q

In pytest-bdd, scenario outlines:

A

Allow parameterization of scenarios using tables