The complexity of websites has increased over the last years. Especially technologies like AJaX or JavaScript allow complex behaviours of websites. Testing these features is a tedious and time consuming task. Additionally these features should in best case be tested after each new feature being deployed to the website. Doing this manually is not an option.
By means of a case study it will be shown how several features of a TYPO3 website can automatically be tested with User Acceptance Tests (UAT) using "Cucumber". "Cucumber" uses every day language to describe tests, so these tests can directly be written by the project manager or even the client. This offers the possibility that these tests can be used to describe the required features of a project.
It will also be shown how the described testing scenario can be integrated within a Continuous Delivery process.
TeamStation AI System Report LATAM IT Salaries 2024
Why Cucumber(s) make your TYPO3 website better
1.
2. Why Cucumber(s) make
your TYPO3 project
better
Søren Schaffstein,
CEO @ dkd Internet Service GmbH
Frankfurt Germany
r
fo s
ble rian
uita ta
s s ege
ki v
tal and
his ns
T a
v eg
35. TDD vs. BDD
Test Driven Behaviour Driven
Technical perspective Business perspective
36. TDD vs. BDD
Test Driven Behaviour Driven
Technical perspective Business perspective
Verification focus Specification focus
37. TDD vs. BDD
Test Driven Behaviour Driven
Technical perspective Business perspective
Verification focus Specification focus
Unit tests Acceptance tests
38. TDD vs. BDD
Test Driven Behaviour Driven
Technical perspective Business perspective
Verification focus Specification focus
Unit tests Acceptance tests
“build the thing right” “build the right thing”
39. TDD vs. BDD
Test Driven Behaviour Driven
Technical perspective Business perspective
Verification focus Specification focus
Unit tests Acceptance tests
“build the thing right” “build the right thing”
Documentation
47. What is an UAT?
The client or user specifies a feature and its
behaviour
48. What is an UAT?
The client or user specifies a feature and its
behaviour
One or more tests are written to verify the
intended behaviour
49. What is an UAT?
The client or user specifies a feature and its
behaviour
One or more tests are written to verify the
intended behaviour
If all tests pass, then the client will accept the
feature as functional
61. Why automated testing is great
It’s easy
It’s fast
It’s cheap
Complex scenarios can be tested regularly
62. Why automated testing is great
It’s easy
It’s fast
It’s cheap
Complex scenarios can be tested regularly
External components can be tested regularly
63. Why automated testing is great
It’s easy
It’s fast
It’s cheap
Complex scenarios can be tested regularly
External components can be tested regularly
It increases the overall quality and robustness
64. Why automated testing is great
It’s easy
It’s fast
It’s cheap
Complex scenarios can be tested regularly
External components can be tested regularly
It increases the overall quality and robustness
Gives a good feeling of control
75. Form aftermath
Send a confirmation mail to the sender
Create a record in the CRM system
76. Form aftermath
Send a confirmation mail to the sender
Create a record in the CRM system
Temporarily save form data to database
77. Form aftermath
Send a confirmation mail to the sender
Create a record in the CRM system
Temporarily save form data to database
For data protection reasons clear form database
entries after a week
80. Recurring tests
Does the website work without “www.”?
Are .htaccess protections switched on/off?
81. Recurring tests
Does the website work without “www.”?
Are .htaccess protections switched on/off?
Does the website contain a legal notice page?
82. Recurring tests
Does the website work without “www.”?
Are .htaccess protections switched on/off?
Does the website contain a legal notice page?
Does the legal notice page contain a
VAT-number?
83. Recurring tests
Does the website work without “www.”?
Are .htaccess protections switched on/off?
Does the website contain a legal notice page?
Does the legal notice page contain a
VAT-number?
Does the search work?
84. Recurring tests
Does the website work without “www.”?
Are .htaccess protections switched on/off?
Does the website contain a legal notice page?
Does the legal notice page contain a
VAT-number?
Does the search work?
Is the standard-functionality of a certain TYPO3
extension provided?
98. Cucumber test structure
Given I am on the homepage
When I click on the contact link
Define the initial situation
Do something
99. Cucumber test structure
Given I am on the homepage
When I click on the contact link
Then I should see the contact form
Define the initial situation
Do something
Examine the outcome
100. Scenario: Show default contact form
Given I am on the homepage
When I click on the contact link
Then I should see the contact form
101. A dash more Gherkin
Scenario: Show default contact form
Given I am on the homepage
When I click on the contact link
Then I should see the contact form
102. Scenario: Show default contact form
Given I am on the homepage
When I click on the contact link
Then I should see the contact form
103. Let’s write some tests for our
form
Scenario: Show default contact form
Given I am on the homepage
When I click on the contact link
Then I should see the contact form
104. Let’s write some tests for our
form
Scenario: Show default contact form
Given I am on the homepage
When I click on the contact link
And I wait for 2 seconds
Then I should see the contact form
105. Scenario: Submit the form
Given I am on the homepage
When I click on the contact link
And I wait for 2 seconds
And I submit the contact form
Then I should see "Thank you!"
106. Submit the form
Scenario: Submit the form
Given I am on the homepage
When I click on the contact link
And I wait for 2 seconds
And I submit the contact form
Then I should see "Thank you!"
107. Submit the form
Scenario: Submit the form
Given I am on the contact form
And I submit the contact form
Then I should see "Thank you!"
108. Scenario: Submit the form without any data
Given I am on the contact form
And I submit the contact form
Then I should see "enter a name"
And I should see "enter an email"
And I should see "enter a phone number"
And I should see "enter a message"
109. How about form validation?
Scenario: Submit the form without any data
Given I am on the contact form
And I submit the contact form
Then I should see "enter a name"
And I should see "enter an email"
And I should see "enter a phone number"
And I should see "enter a message"
110. Scenario: Submit the form with invalid data
Given I am on the contact form
When I fill in "email" with "test"
And I submit the contact form
Then I should see "enter an email"
111. Email validation
Scenario: Submit the form with invalid data
Given I am on the contact form
When I fill in "email" with "test"
And I submit the contact form
Then I should see "enter an email"
112. Email validation
Scenario: Submit the form with invalid data
Given I am on the contact form
When I fill in "email" with "test"
And I submit the contact form
Then I should see "enter an email"
113. Email validation
Scenario Outline: Submit the form with
typical invalid entries for email
Given I am on the contact form
When I fill in "email" with "<test>"
And I submit the contact form
Then I should see "enter an email"
Examples: List of invalid entries
| test |
| not_an_email |
| address@no_tld |
| no_at_symbol.tld |
114.
115. A feature has multiple
Scenarios
Feature: Contact form
116. A feature has multiple
Scenarios
Feature: Contact form
As a website owner I want to have a contact
form so that website visitors can easily
contact us
117. A feature has multiple
Scenarios
Feature: Contact form
As a website owner I want to have a contact
form so that website visitors can easily
contact us
Scenario: Show default contact form
Given I am on the homepage
When I click on the contact link
Then I should see the contact form
118. A feature has multiple
Scenarios
Feature: Contact form
As a website owner I want to have a contact
form so that website visitors can easily
contact us
Scenario: Show default contact form
Given I am on the homepage
When I click on the contact link
Then I should see the contact form
Scenario: Submit the form
Given I am on the contact form
And I submit the contact form
Then I should see "Thank you!"
121. Testing pitfalls
Testing the “wrong” state
Then I should not see "fatal error"
Testing for content on a page that might change
Then I should see "John Doe"
124. My client doesn’t speak
english :(
Gherkin is available in over 40 languages
125. My client doesn’t speak
english :(
Gherkin is available in over 40 languages
Scenario: Show default contact form
Given I am on the homepage
When I click on the contact link
Then I should see the contact form
126. My client doesn’t speak
english :(
Gherkin is available in over 40 languages
Scenario: Show default contact form
Given I am on the homepage
When I click on the contact link
Then I should see the contact form
Scenario: Visa standard kontaktformuläret
Givet jag är på hemsidan
När jag klickar på kontaktlänken
Så jag ska se kontaktformuläret
130. How does Cucumber work?
Write a Scenario in Gherkin
Cucumber reads each step
131. How does Cucumber work?
Write a Scenario in Gherkin
Cucumber reads each step
For each step you can execute Code:
Cucumber = Ruby / Behat = PHP ara
yb s
ap ck
C ro
or ting
f s
we bte
132. How does Cucumber work?
Write a Scenario in Gherkin
Cucumber reads each step
For each step you can execute Code:
Cucumber = Ruby / Behat = PHP ara
yb s
ap ck
C ro
or ting
f s
Cucumber reports about the
we bte
test results
133.
134. What Output do I get?
Cucumber supports different Output formats
135. What Output do I get?
Cucumber supports different Output formats
Feature: Check if the default contact form opens when clicking on the link
Kontakt
Scenario: Show default contact form # features/testfeature.feature:3
Given I am on the homepage # features/steps/simple_steps.rb:1
When I click on the contact link # features/steps/simple_steps.rb:5
TODO (Cucumber::Pending)
./features/steps/simple_steps.rb:6:in `/^I click on the contact link$/'
features/testfeature.feature:5:in `When I click on the contact link'
Then I should see the contact form # features/steps/simple_steps.rb:9
1 scenario (1 pending)
3 steps (1 skipped, 1 pending, 1 passed)
0m14.604s
136. What Output do I get?
Cucumber supports different Output formats
144. $ cat > features/contact_form.feature
Feature: Check if the default contact form opens when clicking on the link
Kontakt
Scenario: Show default contact form
Given I am on the homepage
When I click on the contact link
Then I should see the contact form
<Press ctrl+d>
40s
50s
145. Create Feature file
$ cat > features/contact_form.feature
Feature: Check if the default contact form opens when clicking on the link
Kontakt
Scenario: Show default contact form
Given I am on the homepage
When I click on the contact link
Then I should see the contact form
<Press ctrl+d>
40s
50s
146. $ cat > features/steps/steps.rb
Given /^I am on the homepage$/ do
visit('http://www.dkd.de')
end
When /^I click on the contact link$/ do
click_link('Kontakt')
end
Then /^I should see the contact form$/ do
text = 'Call Back'
if page.respond_to? :should
page.should have_content(text)
else
assert page.has_content?(text)
end
end 30s
<Press ctrl+d>
60s
147. Create step definitions file
$ cat > features/steps/steps.rb
Given /^I am on the homepage$/ do
visit('http://www.dkd.de')
end
When /^I click on the contact link$/ do
click_link('Kontakt')
end
Then /^I should see the contact form$/ do
text = 'Call Back'
if page.respond_to? :should
page.should have_content(text)
else
assert page.has_content?(text)
end
end 30s
<Press ctrl+d>
60s
148. $ cat > features/support/env.rb
# Capybara configuration
require 'capybara'
require 'capybara/cucumber'
Capybara.default_driver = :selenium
Capybara.run_server = false
# set the host of the website you want to test
Capybara.app_host = 'http://www.dkd.de'
<Press ctrl+d>
20s
70s
149. Create settings file
$ cat > features/support/env.rb
# Capybara configuration
require 'capybara'
require 'capybara/cucumber'
Capybara.default_driver = :selenium
Capybara.run_server = false
# set the host of the website you want to test
Capybara.app_host = 'http://www.dkd.de'
<Press ctrl+d>
20s
70s
150. $ cucumber
Feature: Check if the default contact form opens when clicking on the link
Kontakt
Scenario: Show default contact form # features/contact_form.feature:3
Given I am on the homepage # features/steps/steps.rb:1
When I click on the contact link # features/steps/steps.rb:5
Then I should see the contact form # features/steps/steps.rb:9
1 scenario (1 passed)
3 steps (3 passed)
0m18.874s
1s
89s
151. Run Cucumber
$ cucumber
Feature: Check if the default contact form opens when clicking on the link
Kontakt
Scenario: Show default contact form # features/contact_form.feature:3
Given I am on the homepage # features/steps/steps.rb:1
When I click on the contact link # features/steps/steps.rb:5
Then I should see the contact form # features/steps/steps.rb:9
1 scenario (1 passed)
3 steps (3 passed)
0m18.874s
1s
89s
178. dkd
development
kommunikation
design
thank you!
179. Cocktail ingredients
| Quantity | Ingredient |
| 1 l | club soda |
| 250 ml | gin |
| 60 ml | lemon juice |
| 12 slices | lemon |
| 12 slices | cucumber |
| 12 slices | sprigs fresh mint |
Scenario: Refreshing Cucumber Cocktail
Given I have the ingredients
When I combine the club soda, gin and lemon juice
And I place a lemon slice and a cucumber slice in each of 12 glasses
And I add 1 cup crushed ice to each glass
And I pour the gin mixture into the glasses and garnish each with a mint sprig
Then I should get 12 refreshing cocktails
* married to Simone* traveling - photography - scuba diving - LEGOs\n* photography, LEGO, scuba diving, traveling\n
* married to Simone* traveling - photography - scuba diving - LEGOs\n* photography, LEGO, scuba diving, traveling\n
* married to Simone* traveling - photography - scuba diving - LEGOs\n* photography, LEGO, scuba diving, traveling\n
* married to Simone* traveling - photography - scuba diving - LEGOs\n* photography, LEGO, scuba diving, traveling\n
* married to Simone* traveling - photography - scuba diving - LEGOs\n* photography, LEGO, scuba diving, traveling\n
\n
\n
\n
\n
\n
\n
\n
Cucumber Sandwich, a type of sandwich\n
Cucumber, a community in West Virginia, USA\n
Cucumber (TV series), a Canadian children's television series originally broadcast in the 1970s\n
Cucumber Castle, a 1970 album released by the Bee Gees\n
Cucumber beetle, a type of beetle.\n
Sea cucumber, a type of animal\n
Cucumber (software), a Behavior Driven Development tool.\n\n
\n
\n
\n
write tests first then develop\n
write tests first then develop\n
write tests first then develop\n
TDD example: add-function 2+3=5\nBDD example: I&#x2019;d like to add 2+3 and get 5\nIn this talk we will explore BDD a bit further\n
TDD example: add-function 2+3=5\nBDD example: I&#x2019;d like to add 2+3 and get 5\nIn this talk we will explore BDD a bit further\n
TDD example: add-function 2+3=5\nBDD example: I&#x2019;d like to add 2+3 and get 5\nIn this talk we will explore BDD a bit further\n
TDD example: add-function 2+3=5\nBDD example: I&#x2019;d like to add 2+3 and get 5\nIn this talk we will explore BDD a bit further\n
TDD example: add-function 2+3=5\nBDD example: I&#x2019;d like to add 2+3 and get 5\nIn this talk we will explore BDD a bit further\n
TDD example: add-function 2+3=5\nBDD example: I&#x2019;d like to add 2+3 and get 5\nIn this talk we will explore BDD a bit further\n
TDD example: add-function 2+3=5\nBDD example: I&#x2019;d like to add 2+3 and get 5\nIn this talk we will explore BDD a bit further\n
TDD example: add-function 2+3=5\nBDD example: I&#x2019;d like to add 2+3 and get 5\nIn this talk we will explore BDD a bit further\n
TDD example: add-function 2+3=5\nBDD example: I&#x2019;d like to add 2+3 and get 5\nIn this talk we will explore BDD a bit further\n
TDD example: add-function 2+3=5\nBDD example: I&#x2019;d like to add 2+3 and get 5\nIn this talk we will explore BDD a bit further\n
TDD example: add-function 2+3=5\nBDD example: I&#x2019;d like to add 2+3 and get 5\nIn this talk we will explore BDD a bit further\n
TDD example: add-function 2+3=5\nBDD example: I&#x2019;d like to add 2+3 and get 5\nIn this talk we will explore BDD a bit further\n
1: definition is clear between you and the client. Calculation can be done\n2: developers know what to develop and see if they break something\n3: make sure everything stays functional (externals can change: flickr example)\n
1: definition is clear between you and the client. Calculation can be done\n2: developers know what to develop and see if they break something\n3: make sure everything stays functional (externals can change: flickr example)\n
1: definition is clear between you and the client. Calculation can be done\n2: developers know what to develop and see if they break something\n3: make sure everything stays functional (externals can change: flickr example)\n
1: definition is clear between you and the client. Calculation can be done\n2: developers know what to develop and see if they break something\n3: make sure everything stays functional (externals can change: flickr example)\n
1: definition is clear between you and the client. Calculation can be done\n2: developers know what to develop and see if they break something\n3: make sure everything stays functional (externals can change: flickr example)\n
1: definition is clear between you and the client. Calculation can be done\n2: developers know what to develop and see if they break something\n3: make sure everything stays functional (externals can change: flickr example)\n
\n
\n
Feature: contact form Behaviour: \n* Name, email, message field\n* email may not be blank\n* form must be saved to database\n
Feature: contact form Behaviour: \n* Name, email, message field\n* email may not be blank\n* form must be saved to database\n
Feature: contact form Behaviour: \n* Name, email, message field\n* email may not be blank\n* form must be saved to database\n
Feature: contact form Behaviour: \n* Name, email, message field\n* email may not be blank\n* form must be saved to database\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
Video: Contact form: Happy Path\n
Video: contact form validation\n
Video: addressed contact form\n
\n
\n
\n
\n
\n
1 & 2: tend to get forgotten\n
1 & 2: tend to get forgotten\n
1 & 2: tend to get forgotten\n
1 & 2: tend to get forgotten\n
1 & 2: tend to get forgotten\n
1 & 2: tend to get forgotten\n
1 & 2: tend to get forgotten\n
\n
\n
\n
Explain what we want in plain english\n
Explain what we want in plain english\n
Explain what we want in plain english\n
Explain what we want in plain english\n
Explain what we want in plain english\n
Explain what we want in plain english\n
Explain what we want in plain english\n
\n
\n
Each Cucumber test starts without knowing about other tests\n
Each Cucumber test starts without knowing about other tests\n
Each Cucumber test starts without knowing about other tests\n
Each Cucumber test starts without knowing about other tests\n
Each Cucumber test starts without knowing about other tests\n
Each Cucumber test starts without knowing about other tests\n
Each Cucumber test starts without knowing about other tests\n
Introducing the &#x201C;Scenario&#x201D; keyword\n
Ok this was a simple example. But what when it get&#x2019;s more complicated. Is it still easy?\n
Ok this was a simple example. But what when it get&#x2019;s more complicated. Is it still easy?\n
Ok this was a simple example. But what when it get&#x2019;s more complicated. Is it still easy?\n
Just write the important stuff in the tests\n
Just write the important stuff in the tests\n
Just write the important stuff in the tests\n
\n
I don&#x2019;t test the other validation options for two reasons:\n* keep the test short and simple\n* test only one thing at a time (to keep things atomic)\n
I don&#x2019;t test the other validation options for two reasons:\n* keep the test short and simple\n* test only one thing at a time (to keep things atomic)\n
I don&#x2019;t test the other validation options for two reasons:\n* keep the test short and simple\n* test only one thing at a time (to keep things atomic)\n
I don&#x2019;t test the other validation options for two reasons:\n* keep the test short and simple\n* test only one thing at a time (to keep things atomic)\n
I don&#x2019;t test the other validation options for two reasons:\n* keep the test short and simple\n* test only one thing at a time (to keep things atomic)\n
feature\n
feature\n
feature\n
feature\n
feature\n
\n
\n
\n
And yes, it&#x2019;s available in &#x201C;pirate english&#x201D;\n
And yes, it&#x2019;s available in &#x201C;pirate english&#x201D;\n
And yes, it&#x2019;s available in &#x201C;pirate english&#x201D;\n
And yes, it&#x2019;s available in &#x201C;pirate english&#x201D;\n
\n
\n
\n
\n
\n
\n
PDF, JSON\n
PDF, JSON\n
PDF, JSON\n
PDF, JSON\n
PDF, JSON\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
Redmine = Backlog\nReactualize = User Stories\nJenkins = Worker\n
Redmine = Backlog\nReactualize = User Stories\nJenkins = Worker\n
Redmine = Backlog\nReactualize = User Stories\nJenkins = Worker\n
Redmine = Backlog\nReactualize = User Stories\nJenkins = Worker\n
Redmine = Backlog\nReactualize = User Stories\nJenkins = Worker\n
Redmine = Backlog\nReactualize = User Stories\nJenkins = Worker\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
Now&#x2019;s the time to ask your questions\nIf you&#x2019;d like to have a more detailed discussion with me, feel free to visit me at the dkd booth today at XXX or send an email\n