SlideShare ist ein Scribd-Unternehmen logo
1 von 28
Flow Applikationen
mit Behat testen
Markus Goldbeck
Senior Developer typovision GmbH
(c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de
TYPO3 Flow Applikation testen mit Behat
2
Markus Goldbeck
• Senior Developer bei der typovision GmbH
• TYPO3 Neos Member
• @MarkusGoldbeck
(c) 2013 - typovision GmbH | Thema der Präsentation | Autor | www.typovision.de 3
Was ist Behat?
(c) 2013 - typovision GmbH | Thema der Präsentation | Autor | www.typovision.de 4
A php framework for testing
your business expectations.
http://behat.org/
(c) 2013 - typovision GmbH | Thema der Präsentation | Autor | www.typovision.de 5
Aber wir haben doch
Unit und Functional Tests !
(c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de
TYPO3 Flow Applikation testen mit Behat
6
Unit Tests
Unit Tests
• testet funktionale Einzelteile
• sind die inneren und detailliertesten Komponenten der Software
• testet die Module isoliert
• für Modultests müssen externe Komponenten wie
Datenbankverbindungen aufwendig durch Mock-Objekte simuliert
werden
(c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de
TYPO3 Flow Applikation testen mit Behat
7
Functional Tests
Functional Tests
• sind eine Form von Integrationstest
• soll die einzelnen Komponenten zusammen testen
• auch hier muss für das testen mit externen Komponenten wie
Datenbankverbindungen diese aufwendig durch Mock-Objekte
simuliert werden
(c) 2013 - typovision GmbH | Thema der Präsentation | Autor | www.typovision.de 8
Und wofür brauch ich jetzt
noch Behat bzw. BDD ?
(c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de
TYPO3 Flow Applikation testen mit Behat
9
Behavior Driven Development
Behavior Driven Development
• Es werden während der Anforderungsanalyse die
• Aufgaben
• Ziele und
• Ergebnisse textuell festgehalten
• Anforderungen in „Wenn-Dann“- Sätze
• basierend auf ubiquitären Sprache des Domain-Driven Designs
=> einfacher Übergang zwischen fachlicher Anforderung und
Programmiersprache
(c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de
TYPO3 Flow Applikation testen mit Behat
10
Behavior Driven Development
Vorteile
• leichte Lesbarkeit durch „sprechende“ Tests
• Test von „außen“
• könnte vom Stakeholder selber geschrieben werden
• kann von jedem geschrieben werden, der die Business Logik kennt
• durch die Abstraktion der Tests kann sich die Implementierung ändern,
die Funktion bzw. der Test kann aber immer noch funktionieren
=> als Erweiterung für Unit und Functional Tests, um die Business Logik zu
testen
(c) 2013 - typovision GmbH | Thema der Präsentation | Autor | www.typovision.de 11
Einbindung von Behat in
TYPO3 Flow Applikationen
(c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de
TYPO3 Flow Applikation testen mit Behat
12
Einbindung
Flowpack.Behat
• fertiges Flow Package von Christopher Hlubek networkteam GmbH
• https://github.com/Flowpack/Flowpack.Behat
• Einbindung über Composer oder direkt clonen Packages/Application
{
"name": "typo3/neos-base-distribution",
"description" : "TYPO3 Neos Base Distribution",
"license": "GPL-3.0+",
"config": {
"vendor-dir": "Packages/Libraries",
"bin-dir": "bin"
},
"require": {
"typo3/neos": "dev-master",
"typo3/neosdemotypo3org": "dev-master",
"typo3/sitekickstarter": "dev-master"
},
"require-dev": {
"typo3/buildessentials": "dev-master",
"mikey179/vfsstream": "1.1.*",
"flowpack/behat": "dev-master"
},
"minimum-stability": "dev",
"scripts": {
"post-update-cmd": "TYPO3FlowComposerInstallerScripts::postUpdateAndInstall",
"post-install-cmd": "TYPO3FlowComposerInstallerScripts::postUpdateAndInstall"
}
}
(c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de
TYPO3 Flow Applikation testen mit Behat
13
Einbindung
Flow Build path
• https://review.typo3.org/#/c/20756/3
• anlegen des Ordners „Behat“ in „Build“
• Einbindung composer.json
• cd Build/Behat
• composer install --dev
{
	

 "require": {
	

 	

 "behat/behat": "2.4.*",
	

 	

 "behat/mink-extension": "1.0.*",
	

 	

 "behat/mink-goutte-driver": "*",
"behat/mink-selenium2-driver": "*"
	

 },
	

 "config": {
	

 	

 "bin-dir": "../../bin/"
	

 }
}
(c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de
TYPO3 Flow Applikation testen mit Behat
14
Einbindung
Konfiguration
• Behat braucht zwei spezielle Flow Kontexts
• „Development/Behat/Settings.yaml“
• wichtig: Angabe eigener Datenbank
• wichtig: Angabe des „drivers“
TYPO3:
Flow:
persistence:
# It is good practice to not specify user name and password of the database
# connection in this global Settings.yaml file. Rather specify them in the
# settings of the respective context (Production / Development ...).
backendOptions:
host: '127.0.0.1' # adjust to your database host
dbname: 'neosdev_behat' # adjust to your database name
user: 'root' # adjust to your database user
password: 'root' # adjust to your database password
driver: pdo_mysql
(c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de
TYPO3 Flow Applikation testen mit Behat
15
Einbindung
Konfiguration
• Behat braucht zwei spezielle Flow Kontexts
• „Testing/Behat/Settings.yaml“
• wichtig: Angabe eigener Datenbank
• wichtig: Angabe des „drivers“
TYPO3:
Flow:
persistence:
# It is good practice to not specify user name and password of the database
# connection in this global Settings.yaml file. Rather specify them in the
# settings of the respective context (Production / Development ...).
backendOptions:
host: '127.0.0.1' # adjust to your database host
dbname: 'neosdev_behat' # adjust to your database name
user: 'root' # adjust to your database user
password: 'root' # adjust to your database password
driver: pdo_mysql
(c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de
TYPO3 Flow Applikation testen mit Behat
16
Einbindung
Konfiguration vhost
• Behat Konfiguration auf die gleiche Flow Installation
• setzen von „SetEnv FLOW_CONTEXT Development/Behat“ Kontext
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs/NeosDev/Web/"
ServerName neos.dev
ServerAlias neos.dev
SetEnv FLOW_CONTEXT Development
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs/NeosDev/Web/"
ServerName neos.dev.behat
ServerAlias neos.dev.behat
SetEnv FLOW_CONTEXT Development/Behat
</VirtualHost>
(c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de
TYPO3 Flow Applikation testen mit Behat
17
Einbindung
Anlegen der Features
• anlegen von Behavior/Features/Botstrap/FeatureContext.php
• Kopie von behat.yml.dist anlegen und base_url analog zu vhost setzen
(c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de
TYPO3 Flow Applikation testen mit Behat
18
Einbindung
Anlegen der Features
• anlegen von Behavior/Features/Botstrap/FeatureContext.php
• Kopie von behat.yml.dist anlegen und base_url analog zu vhost setzen
require_once(__DIR__ . '/../../../../../Flowpack.Behat/Tests/Behat/FlowContext.php');
/**
* Features context
*/
class FeatureContext extends MinkContext {
}
(c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de
TYPO3 Flow Applikation testen mit Behat
19
Selenium
Testen von JavaScript
• im Beha
• @javascript neben @fixtures
• Download Selenium Server
• java -jar selenium-server-standalone-2.32.0.jar
(c) 2013 - typovision GmbH | Thema der Präsentation | Autor | www.typovision.de 20
Wie sieht so ein Behat Test
aus ?
(c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de
TYPO3 Flow Applikation testen mit Behat
21
Thema des Slides
Feature
Feature: ls
In order to see the directory structure
As a UNIX user
I need to be able to list the current directory's contents
Scenario:
Given I am in a directory "test"
And I have a file named "foo"
And I have a file named "bar"
When I run "ls"
Then I should get:
"""
bar
foo
"""
(c) 2013 - typovision GmbH | Thema der Präsentation | Autor | www.typovision.de 22
Gherkin - Gürkchen ?
(c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de
TYPO3 Flow Applikation testen mit Behat
23
Aufbau
Unterteilung der Tests
• Gherkin als Beschreibungssprache
• features
• Background
• scenarios
• Given
• When
• Then
• But
(c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de
TYPO3 Flow Applikation testen mit Behat
24
Aufruf der Tests
Aufruf der Features aus dem Flow root path
• alle features
bin/behat -v -c Packages/Application/TYPO3.Neos/Tests/Behavior/
behat.yml
• einzelne features
bin/behat -v -c Packages/Application/TYPO3.Neos/Tests/Behavior/
behat.yml Packages/Application/TYPO3.Neos/Tests/Behavior/features/
ContentModule/PreviewMode.feature
• einzelne scenarios
bin/behat -v -c Packages/Application/TYPO3.Neos/Tests/Behavior/
behat.yml Packages/Application/TYPO3.Neos/Tests/Behavior/features/
ContentModule/PageTree.feature:26
(c) 2013 - typovision GmbH | Thema der Präsentation | Autor | www.typovision.de 25
So und jetzt bitte Beispiele
(c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de
TYPO3 Flow Applikation testen mit Behat
26
Behat Tests in TYPO3 Neos
Behat Tests sind bereits in TYPO3 Neos integriert
• steht am Anfang
• Ziel Backend stabiler machen und erhalten
• Beispiele /Packages/Application/TYPO3.Neos/Tests/Behavior
(c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de
TYPO3 Flow Applikation testen mit Behat
27
Quellen
Quellen
• http://behat.org/
• https://de.wikipedia.org/wiki/Modultest
• http://de.wikipedia.org/wiki/Funktionstest
• https://github.com/Flowpack/Flowpack.Behat
• TYPO3.Neos/Documentation/DeveloperGuide/Testing/Behat
• https://speakerdeck.com/everzet/behat-by-example
Vielen Dank für Eure
Aufmerksamkeit

Weitere ähnliche Inhalte

Was ist angesagt?

Regressionstests in Webprojekten
Regressionstests in WebprojektenRegressionstests in Webprojekten
Regressionstests in WebprojektenSebastian Bauer
 
Regressionstests in Webprojekten - IPC12SE
Regressionstests in Webprojekten - IPC12SERegressionstests in Webprojekten - IPC12SE
Regressionstests in Webprojekten - IPC12SESebastian Bauer
 
Von Test nach live mit Rex
Von Test nach live mit RexVon Test nach live mit Rex
Von Test nach live mit Rexinovex GmbH
 
zopyx.plone migration - Plone Hochschultagung 2013
zopyx.plone migration - Plone Hochschultagung 2013zopyx.plone migration - Plone Hochschultagung 2013
zopyx.plone migration - Plone Hochschultagung 2013Andreas Jung
 
Unit Testing einer Zend-Framework 2 Anwendung
Unit Testing einer Zend-Framework 2 AnwendungUnit Testing einer Zend-Framework 2 Anwendung
Unit Testing einer Zend-Framework 2 AnwendungRalf Eggert
 
FMK2015: Erste Schritte mit einem Codeversionierungssystem by Thomas Hirt
FMK2015: Erste Schritte mit einem Codeversionierungssystem by Thomas HirtFMK2015: Erste Schritte mit einem Codeversionierungssystem by Thomas Hirt
FMK2015: Erste Schritte mit einem Codeversionierungssystem by Thomas HirtVerein FM Konferenz
 
Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.
Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.
Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.Torsten Kleiber
 
BED-Con - Tools für den täglichen Kampf als Entwickler
BED-Con - Tools für den täglichen Kampf als EntwicklerBED-Con - Tools für den täglichen Kampf als Entwickler
BED-Con - Tools für den täglichen Kampf als EntwicklerPatrick Baumgartner
 
WPML für mehrsprachige WordPress Websites verwenden
WPML für mehrsprachige WordPress Websites verwendenWPML für mehrsprachige WordPress Websites verwenden
WPML für mehrsprachige WordPress Websites verwendenmechdesign
 
Devops ohne root
Devops ohne rootDevops ohne root
Devops ohne rootcusy GmbH
 
Back to the future - Plone 5.2 und Python 3 Migration am Beispiel Onkopedia
Back to the future - Plone 5.2 und Python 3 Migration am Beispiel OnkopediaBack to the future - Plone 5.2 und Python 3 Migration am Beispiel Onkopedia
Back to the future - Plone 5.2 und Python 3 Migration am Beispiel OnkopediaAndreas Jung
 
Agile Oracle database modeling and development - APEX Connect 2020
Agile Oracle database modeling and development - APEX Connect 2020Agile Oracle database modeling and development - APEX Connect 2020
Agile Oracle database modeling and development - APEX Connect 2020Torsten Kleiber
 

Was ist angesagt? (12)

Regressionstests in Webprojekten
Regressionstests in WebprojektenRegressionstests in Webprojekten
Regressionstests in Webprojekten
 
Regressionstests in Webprojekten - IPC12SE
Regressionstests in Webprojekten - IPC12SERegressionstests in Webprojekten - IPC12SE
Regressionstests in Webprojekten - IPC12SE
 
Von Test nach live mit Rex
Von Test nach live mit RexVon Test nach live mit Rex
Von Test nach live mit Rex
 
zopyx.plone migration - Plone Hochschultagung 2013
zopyx.plone migration - Plone Hochschultagung 2013zopyx.plone migration - Plone Hochschultagung 2013
zopyx.plone migration - Plone Hochschultagung 2013
 
Unit Testing einer Zend-Framework 2 Anwendung
Unit Testing einer Zend-Framework 2 AnwendungUnit Testing einer Zend-Framework 2 Anwendung
Unit Testing einer Zend-Framework 2 Anwendung
 
FMK2015: Erste Schritte mit einem Codeversionierungssystem by Thomas Hirt
FMK2015: Erste Schritte mit einem Codeversionierungssystem by Thomas HirtFMK2015: Erste Schritte mit einem Codeversionierungssystem by Thomas Hirt
FMK2015: Erste Schritte mit einem Codeversionierungssystem by Thomas Hirt
 
Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.
Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.
Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.
 
BED-Con - Tools für den täglichen Kampf als Entwickler
BED-Con - Tools für den täglichen Kampf als EntwicklerBED-Con - Tools für den täglichen Kampf als Entwickler
BED-Con - Tools für den täglichen Kampf als Entwickler
 
WPML für mehrsprachige WordPress Websites verwenden
WPML für mehrsprachige WordPress Websites verwendenWPML für mehrsprachige WordPress Websites verwenden
WPML für mehrsprachige WordPress Websites verwenden
 
Devops ohne root
Devops ohne rootDevops ohne root
Devops ohne root
 
Back to the future - Plone 5.2 und Python 3 Migration am Beispiel Onkopedia
Back to the future - Plone 5.2 und Python 3 Migration am Beispiel OnkopediaBack to the future - Plone 5.2 und Python 3 Migration am Beispiel Onkopedia
Back to the future - Plone 5.2 und Python 3 Migration am Beispiel Onkopedia
 
Agile Oracle database modeling and development - APEX Connect 2020
Agile Oracle database modeling and development - APEX Connect 2020Agile Oracle database modeling and development - APEX Connect 2020
Agile Oracle database modeling and development - APEX Connect 2020
 

Andere mochten auch

T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow
T3CON14EU: Migrating from TYPO3 CMS to TYPO3 FlowT3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow
T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flowmhelmich
 
TYPO3 Flow a solid foundation for medialib.tv
TYPO3 Flow a solid foundation for medialib.tvTYPO3 Flow a solid foundation for medialib.tv
TYPO3 Flow a solid foundation for medialib.tvdfeyer
 
TYPO3 Flow and the Joy of Development (FOSDEM 2013)
TYPO3 Flow and the Joy of Development (FOSDEM 2013)TYPO3 Flow and the Joy of Development (FOSDEM 2013)
TYPO3 Flow and the Joy of Development (FOSDEM 2013)Robert Lemke
 
TYPO3 Flow 2.0 (International PHP Conference 2013)
TYPO3 Flow 2.0 (International PHP Conference 2013)TYPO3 Flow 2.0 (International PHP Conference 2013)
TYPO3 Flow 2.0 (International PHP Conference 2013)Robert Lemke
 
TYPO3 Flow 2.0 in the field - webtech Conference 2013
TYPO3 Flow 2.0 in the field - webtech Conference 2013TYPO3 Flow 2.0 in the field - webtech Conference 2013
TYPO3 Flow 2.0 in the field - webtech Conference 2013die.agilen GmbH
 
TYPO3 Flow 2.0 Workshop T3BOARD13
TYPO3 Flow 2.0 Workshop T3BOARD13TYPO3 Flow 2.0 Workshop T3BOARD13
TYPO3 Flow 2.0 Workshop T3BOARD13Robert Lemke
 
TYPO3 Flow: Beyond the Blog Example (Inspiring Flow 2013)
TYPO3 Flow: Beyond the Blog Example (Inspiring Flow 2013)TYPO3 Flow: Beyond the Blog Example (Inspiring Flow 2013)
TYPO3 Flow: Beyond the Blog Example (Inspiring Flow 2013)Robert Lemke
 
T3CON12 Flow and TYPO3 deployment with surf
T3CON12 Flow and TYPO3 deployment with surfT3CON12 Flow and TYPO3 deployment with surf
T3CON12 Flow and TYPO3 deployment with surfTobias Liebig
 
TYPO3 5.0 Experience Concept
TYPO3 5.0 Experience ConceptTYPO3 5.0 Experience Concept
TYPO3 5.0 Experience ConceptJens Hoffmann
 
TYPO3 Flow - PHP Framework for Developer Happiness
TYPO3 Flow - PHP Framework for Developer HappinessTYPO3 Flow - PHP Framework for Developer Happiness
TYPO3 Flow - PHP Framework for Developer HappinessChristian Müller
 
TYPO3 Surf Introduction
TYPO3 Surf IntroductionTYPO3 Surf Introduction
TYPO3 Surf IntroductionHelmut Hummel
 
Deployment von Entwicklungsumgebungen eines TYPO3-Intranets mit Vagrant
Deployment von Entwicklungsumgebungen eines TYPO3-Intranets mit VagrantDeployment von Entwicklungsumgebungen eines TYPO3-Intranets mit Vagrant
Deployment von Entwicklungsumgebungen eines TYPO3-Intranets mit VagrantChristoph Möller
 
TYPO3 Scalability for high traffic sites
TYPO3 Scalability for high traffic sitesTYPO3 Scalability for high traffic sites
TYPO3 Scalability for high traffic sitesdanospv
 
TYPO3 CMS deployment with Jenkins CI
TYPO3 CMS deployment with Jenkins CITYPO3 CMS deployment with Jenkins CI
TYPO3 CMS deployment with Jenkins CIderdanne
 
Make Your TYPO3 Web Sites Fly
Make Your TYPO3 Web Sites FlyMake Your TYPO3 Web Sites Fly
Make Your TYPO3 Web Sites Flyjweiland
 
Scalable Deployment Architectures with TYPO3 Surf, Git and Jenkins
Scalable Deployment Architectures with TYPO3 Surf, Git and JenkinsScalable Deployment Architectures with TYPO3 Surf, Git and Jenkins
Scalable Deployment Architectures with TYPO3 Surf, Git and Jenkinsmhelmich
 
TYPO3 Neos - past, present and future (T3CON14EU)
TYPO3 Neos - past, present and future (T3CON14EU)TYPO3 Neos - past, present and future (T3CON14EU)
TYPO3 Neos - past, present and future (T3CON14EU)Robert Lemke
 
Using Document Databases with TYPO3 Flow
Using Document Databases with TYPO3 FlowUsing Document Databases with TYPO3 Flow
Using Document Databases with TYPO3 FlowKarsten Dambekalns
 

Andere mochten auch (18)

T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow
T3CON14EU: Migrating from TYPO3 CMS to TYPO3 FlowT3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow
T3CON14EU: Migrating from TYPO3 CMS to TYPO3 Flow
 
TYPO3 Flow a solid foundation for medialib.tv
TYPO3 Flow a solid foundation for medialib.tvTYPO3 Flow a solid foundation for medialib.tv
TYPO3 Flow a solid foundation for medialib.tv
 
TYPO3 Flow and the Joy of Development (FOSDEM 2013)
TYPO3 Flow and the Joy of Development (FOSDEM 2013)TYPO3 Flow and the Joy of Development (FOSDEM 2013)
TYPO3 Flow and the Joy of Development (FOSDEM 2013)
 
TYPO3 Flow 2.0 (International PHP Conference 2013)
TYPO3 Flow 2.0 (International PHP Conference 2013)TYPO3 Flow 2.0 (International PHP Conference 2013)
TYPO3 Flow 2.0 (International PHP Conference 2013)
 
TYPO3 Flow 2.0 in the field - webtech Conference 2013
TYPO3 Flow 2.0 in the field - webtech Conference 2013TYPO3 Flow 2.0 in the field - webtech Conference 2013
TYPO3 Flow 2.0 in the field - webtech Conference 2013
 
TYPO3 Flow 2.0 Workshop T3BOARD13
TYPO3 Flow 2.0 Workshop T3BOARD13TYPO3 Flow 2.0 Workshop T3BOARD13
TYPO3 Flow 2.0 Workshop T3BOARD13
 
TYPO3 Flow: Beyond the Blog Example (Inspiring Flow 2013)
TYPO3 Flow: Beyond the Blog Example (Inspiring Flow 2013)TYPO3 Flow: Beyond the Blog Example (Inspiring Flow 2013)
TYPO3 Flow: Beyond the Blog Example (Inspiring Flow 2013)
 
T3CON12 Flow and TYPO3 deployment with surf
T3CON12 Flow and TYPO3 deployment with surfT3CON12 Flow and TYPO3 deployment with surf
T3CON12 Flow and TYPO3 deployment with surf
 
TYPO3 5.0 Experience Concept
TYPO3 5.0 Experience ConceptTYPO3 5.0 Experience Concept
TYPO3 5.0 Experience Concept
 
TYPO3 Flow - PHP Framework for Developer Happiness
TYPO3 Flow - PHP Framework for Developer HappinessTYPO3 Flow - PHP Framework for Developer Happiness
TYPO3 Flow - PHP Framework for Developer Happiness
 
TYPO3 Surf Introduction
TYPO3 Surf IntroductionTYPO3 Surf Introduction
TYPO3 Surf Introduction
 
Deployment von Entwicklungsumgebungen eines TYPO3-Intranets mit Vagrant
Deployment von Entwicklungsumgebungen eines TYPO3-Intranets mit VagrantDeployment von Entwicklungsumgebungen eines TYPO3-Intranets mit Vagrant
Deployment von Entwicklungsumgebungen eines TYPO3-Intranets mit Vagrant
 
TYPO3 Scalability for high traffic sites
TYPO3 Scalability for high traffic sitesTYPO3 Scalability for high traffic sites
TYPO3 Scalability for high traffic sites
 
TYPO3 CMS deployment with Jenkins CI
TYPO3 CMS deployment with Jenkins CITYPO3 CMS deployment with Jenkins CI
TYPO3 CMS deployment with Jenkins CI
 
Make Your TYPO3 Web Sites Fly
Make Your TYPO3 Web Sites FlyMake Your TYPO3 Web Sites Fly
Make Your TYPO3 Web Sites Fly
 
Scalable Deployment Architectures with TYPO3 Surf, Git and Jenkins
Scalable Deployment Architectures with TYPO3 Surf, Git and JenkinsScalable Deployment Architectures with TYPO3 Surf, Git and Jenkins
Scalable Deployment Architectures with TYPO3 Surf, Git and Jenkins
 
TYPO3 Neos - past, present and future (T3CON14EU)
TYPO3 Neos - past, present and future (T3CON14EU)TYPO3 Neos - past, present and future (T3CON14EU)
TYPO3 Neos - past, present and future (T3CON14EU)
 
Using Document Databases with TYPO3 Flow
Using Document Databases with TYPO3 FlowUsing Document Databases with TYPO3 Flow
Using Document Databases with TYPO3 Flow
 

Ähnlich wie Testing TYPO3 Flow Applications with Behat

TYPO3 CMS 6.0 - Die Neuerungen (typovision GmbH)
TYPO3 CMS 6.0 - Die Neuerungen (typovision GmbH)TYPO3 CMS 6.0 - Die Neuerungen (typovision GmbH)
TYPO3 CMS 6.0 - Die Neuerungen (typovision GmbH)die.agilen GmbH
 
Typo3 cms-6-0-die-neuerungen
Typo3 cms-6-0-die-neuerungenTypo3 cms-6-0-die-neuerungen
Typo3 cms-6-0-die-neuerungenMokhtar Slama
 
TYPO3 Neos - ein technischer Überblick - DWX 2013
TYPO3 Neos - ein technischer Überblick - DWX 2013TYPO3 Neos - ein technischer Überblick - DWX 2013
TYPO3 Neos - ein technischer Überblick - DWX 2013die.agilen GmbH
 
Extbase & Fluid Einführung - MTUG - Patrick Lobacher
Extbase & Fluid Einführung - MTUG - Patrick LobacherExtbase & Fluid Einführung - MTUG - Patrick Lobacher
Extbase & Fluid Einführung - MTUG - Patrick Lobacherdie.agilen GmbH
 
DevOps - Mehr Geschwindigkeit auf der Schiene
DevOps - Mehr Geschwindigkeit auf der SchieneDevOps - Mehr Geschwindigkeit auf der Schiene
DevOps - Mehr Geschwindigkeit auf der SchieneVorname Nachname
 
Make your IBM connections deployment your own - customize it
Make your IBM connections deployment your own - customize itMake your IBM connections deployment your own - customize it
Make your IBM connections deployment your own - customize itBelsoft
 
FLOW3 Einführung auf dem TYPO3Camp Berlin 2012
FLOW3 Einführung auf dem TYPO3Camp Berlin 2012FLOW3 Einführung auf dem TYPO3Camp Berlin 2012
FLOW3 Einführung auf dem TYPO3Camp Berlin 2012Christof Rodejohann
 
TYPO3 Neos - Next Generation CMS (IPC 2014)
TYPO3 Neos - Next Generation CMS (IPC 2014)TYPO3 Neos - Next Generation CMS (IPC 2014)
TYPO3 Neos - Next Generation CMS (IPC 2014)die.agilen GmbH
 
Vortragsreihe Dortmund: Unified Development Environments
Vortragsreihe Dortmund: Unified Development EnvironmentsVortragsreihe Dortmund: Unified Development Environments
Vortragsreihe Dortmund: Unified Development EnvironmentsThorsten Kamann
 
Typo3 4.3 Die Neuerungen im Überblick
Typo3 4.3 Die Neuerungen im ÜberblickTypo3 4.3 Die Neuerungen im Überblick
Typo3 4.3 Die Neuerungen im Überblickdie.agilen GmbH
 
DDD - Domain Driven Design - TYPO3camp Stuttgart 2011
DDD - Domain Driven Design - TYPO3camp Stuttgart 2011DDD - Domain Driven Design - TYPO3camp Stuttgart 2011
DDD - Domain Driven Design - TYPO3camp Stuttgart 2011die.agilen GmbH
 
Gradle - Beginner's Workshop (german)
Gradle - Beginner's Workshop (german)Gradle - Beginner's Workshop (german)
Gradle - Beginner's Workshop (german)Joachim Baumann
 
TYPO3 CMS 6.1 - Die Neuerungen - typovision GmbH
TYPO3 CMS 6.1 - Die Neuerungen - typovision GmbHTYPO3 CMS 6.1 - Die Neuerungen - typovision GmbH
TYPO3 CMS 6.1 - Die Neuerungen - typovision GmbHdie.agilen GmbH
 
Composer und TYPO3
Composer und TYPO3Composer und TYPO3
Composer und TYPO3Peter Kraume
 
20040921 Serviceorientierte Architektur für WebSphere und WebSphere Portal
20040921 Serviceorientierte Architektur für WebSphere und WebSphere Portal20040921 Serviceorientierte Architektur für WebSphere und WebSphere Portal
20040921 Serviceorientierte Architektur für WebSphere und WebSphere PortalFrank Rahn
 
Domain-driven design - eine Einführung
Domain-driven design - eine EinführungDomain-driven design - eine Einführung
Domain-driven design - eine Einführungdie.agilen GmbH
 
Domain-Driven Design in der Praxis
Domain-Driven Design in der PraxisDomain-Driven Design in der Praxis
Domain-Driven Design in der PraxisMichael Mirold
 
Make Your IBM Connections Deployment Your Own - Customize it! German Version
Make Your IBM Connections Deployment Your Own - Customize it! German VersionMake Your IBM Connections Deployment Your Own - Customize it! German Version
Make Your IBM Connections Deployment Your Own - Customize it! German VersionKlaus Bild
 
Update TYPO3 V4.5 > 6.2 LTS
Update TYPO3 V4.5 > 6.2 LTSUpdate TYPO3 V4.5 > 6.2 LTS
Update TYPO3 V4.5 > 6.2 LTSCS2 AG
 

Ähnlich wie Testing TYPO3 Flow Applications with Behat (20)

TYPO3 CMS 6.0 - Die Neuerungen (typovision GmbH)
TYPO3 CMS 6.0 - Die Neuerungen (typovision GmbH)TYPO3 CMS 6.0 - Die Neuerungen (typovision GmbH)
TYPO3 CMS 6.0 - Die Neuerungen (typovision GmbH)
 
Typo3 cms-6-0-die-neuerungen
Typo3 cms-6-0-die-neuerungenTypo3 cms-6-0-die-neuerungen
Typo3 cms-6-0-die-neuerungen
 
TYPO3 Neos - ein technischer Überblick - DWX 2013
TYPO3 Neos - ein technischer Überblick - DWX 2013TYPO3 Neos - ein technischer Überblick - DWX 2013
TYPO3 Neos - ein technischer Überblick - DWX 2013
 
Extbase & Fluid Einführung - MTUG - Patrick Lobacher
Extbase & Fluid Einführung - MTUG - Patrick LobacherExtbase & Fluid Einführung - MTUG - Patrick Lobacher
Extbase & Fluid Einführung - MTUG - Patrick Lobacher
 
DevOps - Mehr Geschwindigkeit auf der Schiene
DevOps - Mehr Geschwindigkeit auf der SchieneDevOps - Mehr Geschwindigkeit auf der Schiene
DevOps - Mehr Geschwindigkeit auf der Schiene
 
Make your IBM connections deployment your own - customize it
Make your IBM connections deployment your own - customize itMake your IBM connections deployment your own - customize it
Make your IBM connections deployment your own - customize it
 
FLOW3 Einführung auf dem TYPO3Camp Berlin 2012
FLOW3 Einführung auf dem TYPO3Camp Berlin 2012FLOW3 Einführung auf dem TYPO3Camp Berlin 2012
FLOW3 Einführung auf dem TYPO3Camp Berlin 2012
 
TYPO3 Neos - Next Generation CMS (IPC 2014)
TYPO3 Neos - Next Generation CMS (IPC 2014)TYPO3 Neos - Next Generation CMS (IPC 2014)
TYPO3 Neos - Next Generation CMS (IPC 2014)
 
Vortragsreihe Dortmund: Unified Development Environments
Vortragsreihe Dortmund: Unified Development EnvironmentsVortragsreihe Dortmund: Unified Development Environments
Vortragsreihe Dortmund: Unified Development Environments
 
Typo3 4.3 Die Neuerungen im Überblick
Typo3 4.3 Die Neuerungen im ÜberblickTypo3 4.3 Die Neuerungen im Überblick
Typo3 4.3 Die Neuerungen im Überblick
 
DDD - Domain Driven Design - TYPO3camp Stuttgart 2011
DDD - Domain Driven Design - TYPO3camp Stuttgart 2011DDD - Domain Driven Design - TYPO3camp Stuttgart 2011
DDD - Domain Driven Design - TYPO3camp Stuttgart 2011
 
Gradle - Beginner's Workshop (german)
Gradle - Beginner's Workshop (german)Gradle - Beginner's Workshop (german)
Gradle - Beginner's Workshop (german)
 
TYPO3 CMS 6.1 - Die Neuerungen - typovision GmbH
TYPO3 CMS 6.1 - Die Neuerungen - typovision GmbHTYPO3 CMS 6.1 - Die Neuerungen - typovision GmbH
TYPO3 CMS 6.1 - Die Neuerungen - typovision GmbH
 
Composer und TYPO3
Composer und TYPO3Composer und TYPO3
Composer und TYPO3
 
20040921 Serviceorientierte Architektur für WebSphere und WebSphere Portal
20040921 Serviceorientierte Architektur für WebSphere und WebSphere Portal20040921 Serviceorientierte Architektur für WebSphere und WebSphere Portal
20040921 Serviceorientierte Architektur für WebSphere und WebSphere Portal
 
Domain-driven design - eine Einführung
Domain-driven design - eine EinführungDomain-driven design - eine Einführung
Domain-driven design - eine Einführung
 
Domain-Driven Design in der Praxis
Domain-Driven Design in der PraxisDomain-Driven Design in der Praxis
Domain-Driven Design in der Praxis
 
TYPO3 Neos in der Praxis
TYPO3 Neos in der PraxisTYPO3 Neos in der Praxis
TYPO3 Neos in der Praxis
 
Make Your IBM Connections Deployment Your Own - Customize it! German Version
Make Your IBM Connections Deployment Your Own - Customize it! German VersionMake Your IBM Connections Deployment Your Own - Customize it! German Version
Make Your IBM Connections Deployment Your Own - Customize it! German Version
 
Update TYPO3 V4.5 > 6.2 LTS
Update TYPO3 V4.5 > 6.2 LTSUpdate TYPO3 V4.5 > 6.2 LTS
Update TYPO3 V4.5 > 6.2 LTS
 

Testing TYPO3 Flow Applications with Behat

  • 1. Flow Applikationen mit Behat testen Markus Goldbeck Senior Developer typovision GmbH
  • 2. (c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de TYPO3 Flow Applikation testen mit Behat 2 Markus Goldbeck • Senior Developer bei der typovision GmbH • TYPO3 Neos Member • @MarkusGoldbeck
  • 3. (c) 2013 - typovision GmbH | Thema der Präsentation | Autor | www.typovision.de 3 Was ist Behat?
  • 4. (c) 2013 - typovision GmbH | Thema der Präsentation | Autor | www.typovision.de 4 A php framework for testing your business expectations. http://behat.org/
  • 5. (c) 2013 - typovision GmbH | Thema der Präsentation | Autor | www.typovision.de 5 Aber wir haben doch Unit und Functional Tests !
  • 6. (c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de TYPO3 Flow Applikation testen mit Behat 6 Unit Tests Unit Tests • testet funktionale Einzelteile • sind die inneren und detailliertesten Komponenten der Software • testet die Module isoliert • für Modultests müssen externe Komponenten wie Datenbankverbindungen aufwendig durch Mock-Objekte simuliert werden
  • 7. (c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de TYPO3 Flow Applikation testen mit Behat 7 Functional Tests Functional Tests • sind eine Form von Integrationstest • soll die einzelnen Komponenten zusammen testen • auch hier muss für das testen mit externen Komponenten wie Datenbankverbindungen diese aufwendig durch Mock-Objekte simuliert werden
  • 8. (c) 2013 - typovision GmbH | Thema der Präsentation | Autor | www.typovision.de 8 Und wofür brauch ich jetzt noch Behat bzw. BDD ?
  • 9. (c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de TYPO3 Flow Applikation testen mit Behat 9 Behavior Driven Development Behavior Driven Development • Es werden während der Anforderungsanalyse die • Aufgaben • Ziele und • Ergebnisse textuell festgehalten • Anforderungen in „Wenn-Dann“- Sätze • basierend auf ubiquitären Sprache des Domain-Driven Designs => einfacher Übergang zwischen fachlicher Anforderung und Programmiersprache
  • 10. (c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de TYPO3 Flow Applikation testen mit Behat 10 Behavior Driven Development Vorteile • leichte Lesbarkeit durch „sprechende“ Tests • Test von „außen“ • könnte vom Stakeholder selber geschrieben werden • kann von jedem geschrieben werden, der die Business Logik kennt • durch die Abstraktion der Tests kann sich die Implementierung ändern, die Funktion bzw. der Test kann aber immer noch funktionieren => als Erweiterung für Unit und Functional Tests, um die Business Logik zu testen
  • 11. (c) 2013 - typovision GmbH | Thema der Präsentation | Autor | www.typovision.de 11 Einbindung von Behat in TYPO3 Flow Applikationen
  • 12. (c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de TYPO3 Flow Applikation testen mit Behat 12 Einbindung Flowpack.Behat • fertiges Flow Package von Christopher Hlubek networkteam GmbH • https://github.com/Flowpack/Flowpack.Behat • Einbindung über Composer oder direkt clonen Packages/Application { "name": "typo3/neos-base-distribution", "description" : "TYPO3 Neos Base Distribution", "license": "GPL-3.0+", "config": { "vendor-dir": "Packages/Libraries", "bin-dir": "bin" }, "require": { "typo3/neos": "dev-master", "typo3/neosdemotypo3org": "dev-master", "typo3/sitekickstarter": "dev-master" }, "require-dev": { "typo3/buildessentials": "dev-master", "mikey179/vfsstream": "1.1.*", "flowpack/behat": "dev-master" }, "minimum-stability": "dev", "scripts": { "post-update-cmd": "TYPO3FlowComposerInstallerScripts::postUpdateAndInstall", "post-install-cmd": "TYPO3FlowComposerInstallerScripts::postUpdateAndInstall" } }
  • 13. (c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de TYPO3 Flow Applikation testen mit Behat 13 Einbindung Flow Build path • https://review.typo3.org/#/c/20756/3 • anlegen des Ordners „Behat“ in „Build“ • Einbindung composer.json • cd Build/Behat • composer install --dev { "require": { "behat/behat": "2.4.*", "behat/mink-extension": "1.0.*", "behat/mink-goutte-driver": "*", "behat/mink-selenium2-driver": "*" }, "config": { "bin-dir": "../../bin/" } }
  • 14. (c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de TYPO3 Flow Applikation testen mit Behat 14 Einbindung Konfiguration • Behat braucht zwei spezielle Flow Kontexts • „Development/Behat/Settings.yaml“ • wichtig: Angabe eigener Datenbank • wichtig: Angabe des „drivers“ TYPO3: Flow: persistence: # It is good practice to not specify user name and password of the database # connection in this global Settings.yaml file. Rather specify them in the # settings of the respective context (Production / Development ...). backendOptions: host: '127.0.0.1' # adjust to your database host dbname: 'neosdev_behat' # adjust to your database name user: 'root' # adjust to your database user password: 'root' # adjust to your database password driver: pdo_mysql
  • 15. (c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de TYPO3 Flow Applikation testen mit Behat 15 Einbindung Konfiguration • Behat braucht zwei spezielle Flow Kontexts • „Testing/Behat/Settings.yaml“ • wichtig: Angabe eigener Datenbank • wichtig: Angabe des „drivers“ TYPO3: Flow: persistence: # It is good practice to not specify user name and password of the database # connection in this global Settings.yaml file. Rather specify them in the # settings of the respective context (Production / Development ...). backendOptions: host: '127.0.0.1' # adjust to your database host dbname: 'neosdev_behat' # adjust to your database name user: 'root' # adjust to your database user password: 'root' # adjust to your database password driver: pdo_mysql
  • 16. (c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de TYPO3 Flow Applikation testen mit Behat 16 Einbindung Konfiguration vhost • Behat Konfiguration auf die gleiche Flow Installation • setzen von „SetEnv FLOW_CONTEXT Development/Behat“ Kontext <VirtualHost *:80> DocumentRoot "/Applications/MAMP/htdocs/NeosDev/Web/" ServerName neos.dev ServerAlias neos.dev SetEnv FLOW_CONTEXT Development </VirtualHost> <VirtualHost *:80> DocumentRoot "/Applications/MAMP/htdocs/NeosDev/Web/" ServerName neos.dev.behat ServerAlias neos.dev.behat SetEnv FLOW_CONTEXT Development/Behat </VirtualHost>
  • 17. (c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de TYPO3 Flow Applikation testen mit Behat 17 Einbindung Anlegen der Features • anlegen von Behavior/Features/Botstrap/FeatureContext.php • Kopie von behat.yml.dist anlegen und base_url analog zu vhost setzen
  • 18. (c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de TYPO3 Flow Applikation testen mit Behat 18 Einbindung Anlegen der Features • anlegen von Behavior/Features/Botstrap/FeatureContext.php • Kopie von behat.yml.dist anlegen und base_url analog zu vhost setzen require_once(__DIR__ . '/../../../../../Flowpack.Behat/Tests/Behat/FlowContext.php'); /** * Features context */ class FeatureContext extends MinkContext { }
  • 19. (c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de TYPO3 Flow Applikation testen mit Behat 19 Selenium Testen von JavaScript • im Beha • @javascript neben @fixtures • Download Selenium Server • java -jar selenium-server-standalone-2.32.0.jar
  • 20. (c) 2013 - typovision GmbH | Thema der Präsentation | Autor | www.typovision.de 20 Wie sieht so ein Behat Test aus ?
  • 21. (c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de TYPO3 Flow Applikation testen mit Behat 21 Thema des Slides Feature Feature: ls In order to see the directory structure As a UNIX user I need to be able to list the current directory's contents Scenario: Given I am in a directory "test" And I have a file named "foo" And I have a file named "bar" When I run "ls" Then I should get: """ bar foo """
  • 22. (c) 2013 - typovision GmbH | Thema der Präsentation | Autor | www.typovision.de 22 Gherkin - Gürkchen ?
  • 23. (c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de TYPO3 Flow Applikation testen mit Behat 23 Aufbau Unterteilung der Tests • Gherkin als Beschreibungssprache • features • Background • scenarios • Given • When • Then • But
  • 24. (c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de TYPO3 Flow Applikation testen mit Behat 24 Aufruf der Tests Aufruf der Features aus dem Flow root path • alle features bin/behat -v -c Packages/Application/TYPO3.Neos/Tests/Behavior/ behat.yml • einzelne features bin/behat -v -c Packages/Application/TYPO3.Neos/Tests/Behavior/ behat.yml Packages/Application/TYPO3.Neos/Tests/Behavior/features/ ContentModule/PreviewMode.feature • einzelne scenarios bin/behat -v -c Packages/Application/TYPO3.Neos/Tests/Behavior/ behat.yml Packages/Application/TYPO3.Neos/Tests/Behavior/features/ ContentModule/PageTree.feature:26
  • 25. (c) 2013 - typovision GmbH | Thema der Präsentation | Autor | www.typovision.de 25 So und jetzt bitte Beispiele
  • 26. (c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de TYPO3 Flow Applikation testen mit Behat 26 Behat Tests in TYPO3 Neos Behat Tests sind bereits in TYPO3 Neos integriert • steht am Anfang • Ziel Backend stabiler machen und erhalten • Beispiele /Packages/Application/TYPO3.Neos/Tests/Behavior
  • 27. (c) 2013 - typovision GmbH | TYPO3 Flow Applikation mit Behat testen| Markus Goldbeck | www.typovision.de TYPO3 Flow Applikation testen mit Behat 27 Quellen Quellen • http://behat.org/ • https://de.wikipedia.org/wiki/Modultest • http://de.wikipedia.org/wiki/Funktionstest • https://github.com/Flowpack/Flowpack.Behat • TYPO3.Neos/Documentation/DeveloperGuide/Testing/Behat • https://speakerdeck.com/everzet/behat-by-example
  • 28. Vielen Dank für Eure Aufmerksamkeit