2. Today’s topics
1. What is Cucumber
2. Consequences of using Zephyr and Cucumber together
3. Tips and tricks of step definition creation
2
3. Cucumber
• A cucumber is a tool based on Behavior
Driven Development (BDD) framework
which is used to write acceptance tests
for the applications.
It allows automation of functional
validation in easily readable and
understandable format (like plain
English) to Business Analysts, Developers,
Testers, etc.
3
4. Gherkin Key Words
Cucumber uses Business Readable, Domain Specific Language Gherkin
that requires key words:
• Feature
• Scenario
• Background
• Scenario Outline + Examples
• Given, When, Then, And, But, * …
4
6. Cucumber Key Words: Scenario Outline
6
Things to remember:
• Outline <variables> can be used in scenario names
• Outline <variables> replaces part of a step
• Examples can be logically divided
8. Zephyr-Sync
• Zephyr Sync is a tool, that allows your project to perform
synchronization of automated test results to Zephyr - a JIRA addon
for Test Management.
8
13. Step Definition: Custom Steps Benefits
Custom Steps:
• Describe system from user goals point of view;
• Make scenario self-descriptive;
• Are more flexible in relation to your project;
• Are unified in style and readable;
Well, it depends only from you how good they will be.
13
15. Step Definitions: Key Words
• Given
• When
• Then
• And
• But
• *
15
Given object X should not exist
When object X is created
Then object X should exist
Given object X is created
When object X is deleted
Then object X should not exist
16. Step Definition: Styling
• Action-oriented
And do something
And press the button
And check something
• Subject-oriented
And cukes does something
And I press the button
And the user checks something
• Object-oriented
And it is done
And button is pressed
And something should happen
16
17. Step Definition: Word Selection
• And object X is Y
• And object X is created
• And object X is updated
• And object X is deleted
17
• And object X should exist
• And object X value should contain Y
• And object X value should be equal to Y
• And object X value should be empty
• And object X should not exist
• And object X value should not contain Y
• And object X value should not be equal to Y
• And object X value should not be empty
18. Step Definition: Phrase Structure
• And '%type% object 'X' attribute 'Y' value 'Z'‘
• And LDAP entity by DN 'A' attribute 'B' value 'C' should be equal to 'D'
18
19. Step Definition: Dependencies
• Dependent Steps
Given prepare new entity modification
When change attribute “A" replace value “X"
Then the client updates entity with DN “DN" using prepared modifications
• Independent Steps
And LDAP entity by DN “DN" attribute “A" value “X" is modified with operation "replace“
• Multiaction
And LDAP entity by DN “DN" is updated:
| attribute | value | operation |
| attr1 | value1 | replace |
19
20. Step Definition: Dependencies with Assert
• Dependent Steps:
When the client retrieves entity by DN “DN"
Then entity contains attribute "A" with value "X"
And entity contains attribute “B" with value “Y"
• Independent Steps:
Then LDAP entity by DN “DN” attribute “B” value should not be equal to “Y”
• Or with SoftAssertion multicheck:
Then LDAP entity by DN “DN” attributes should match:
| attribute | value |
| A | X |
| B | Y |
20
21. Step Definition: Multiactions
• Use DataTable types!
• List<K> dataTable
Given a list of numbers
| 17 |
| 42 |
• Map<K,V> dataTable
Given the price list for a coffee shop
| coffee | 1 |
| donut | 2 |
• List<Map<K,V>> dataTable
Given the price list for an international coffee shop
| product | currency | price |
| coffee | EUR | 1 |
| donut | SEK | 18 |
• And don’t forget ContextInflater!
21
23. Step Definitions: Combination
• Use the Power of RegExp!
• Scenario Steps:
Then typeA object 'A' should exist
Then typeB object 'B' should not exist
• Step Definition:
@And(^(typeA|typeB) object '(.+)' should (not| )exist$)
public void checkObjectExists (String type, String name, String condition) {
Boolean shouldExist = condition.isEmpty();
//and other logic
}
23
24. Step Definition Development: Logs & Asserts
• How to show hidden information?
• Asserts for failing scenario by rule steps;
• Loggers to view them all;
• Last Action Hero:
• Debugger!
24