SlideShare a Scribd company logo
Testing the frontend,
a brief introduction to the main techniques and tools.
Cluj-Napoca, 13th November 2015
ABOUT
2
•  senior it developer @ publicis pixelpark
•  experience since 1998
•  supporting:
•  processes
•  infrastructure
•  quality assurance
heiko hardt
Mission
3
MISSION
voting module
The user
should be able to vote on a topic
should enter a name and an email address for voting
should vote once a topic
The topic
should be maintained in a protected frontend area
The results
should be shown in a protected frontend area
4
MISSION
voting module, scribble
5
buttons
Please enter your name
and Email address
Email:
Name:
NOYES BACK
Oooops an error...
voting
Well done...
What do you think
about ... ?
VOTE
Yes
1023 No
536
teaser
message(s)
topic
formresult
unit- and integration tests
6
UNIT- AND INTEGRATION TESTS
7
Jasmine is a behavior-driven development
framework for testing JavaScript code.
(Source: http://jasmine.github.io)
UNIT- AND INTEGRATION TESTS
8
jasmine, filetype and structure
spec(s)?
it('should give me a brief introduction', function() {

// expect ...

});
*.spec.js?
In jasmine the tests are written in a *spec.js file.
I prefer using the „source-file-name“.spec.js
src/t3ee_voting_example.js = spec/t3ee_voting_example.spec.js
suite(s)?
describe('This awesome session', function() {

// should be ...

});
UNIT- AND INTEGRATION TESTS
9
jasmine, spec and suite example
spec/t3ee_voting_example.spec.js
// suite
describe('This awesome session', function() {

// spec

it('should give me a brief introduction', function() {


// matcher...


});



});
Results in: This awesome session should give me a brief introduction J
UNIT- AND INTEGRATION TESTS
10
jasmine, expectation ... toBe or not.toBet
not.toBe()
By using „not“ you are able to test against a negative/reverted „given“
expect(argument).not.toBe(given)
expect(false).not.toBe(true)
expectation
All tests are written in expectations. You expect that an „argument or obj or ...“ will „match“
expect(argument).matcher
toBe()
The matcher „toBe“ test if the „argument“ is the same like „given“
expect(argument).toBe(given)
expect(1+2).toBe(3)
UNIT- AND INTEGRATION TESTS
11
jasmine, expectation ... spy
toBeCalledWith(argument)
document.getElementsByClassName(„tester“)
expect(window.document, getElementsByClassName).toBeCalledWidth(„tester“)
spyOn(object, function)
spyOn(window.document, "getElementsByClassName");
toBeCalled()
document.getElementsByClassName(„tester“)
expect(window.document, getElementsByClassName).toBeCalled()
practical part
t3ee_voting_example
12
UNIT- AND INTEGRATION TESTS
13
karma
Karma - Spectacular Test Runner for Javascript
PRACTICAL PART
14
karma
setup intellij / phpstorm / ...
Menu -> Run -> Edit Configuration
Add (+) Karma
Setup Configuration file to karma.conf.js
setup karma via node package manager
# npm init
# npm install karma –save-dev
# node_modules/karma/bin/karma init
start and run
# node_modules/karma/bin/karma start
# node_modules/karma/bin/karma run
PRACTICAL PART
15
karma - code coverage
edit karma.conf.js: reporter
reporters: ['progress', 'coverage'],
install karma-coverage via node package manager
# npm install karma-coverage --save-dev
edit karma.conf.js: preprocessor
preprocessors: {

'src/*.js': ['coverage']

},

UNIT- AND INTEGRATION TESTS
16
grunt
grunt, a javascript task runner
PRACTICAL PART
17
grunt
install grunt
# npm install grunt --save-dev
# npm install grunt-cli --save-dev
install uglify
# npm install grunt-contrib-uglify --save-dev
PRACTICAL PART
18
grunt
Gruntfile.js
module.exports = function(grunt) {
grunt.initConfig({
uglify: {
options: {
beautify: { width: 80, beautify: true },
compress: { global_defs: { "jasmine" : false }, dead_code: true }
},
my_target: { files:{'src/t3ee_voting_example.min.js’:['src/t3ee_voting_example.js’]}}
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.registerTask('default', ['uglify']);
};
PRACTICAL PART
19
grunt
execute
# grunt
functional- and acceptance test
20
FUNCTIONAL- AND ACCEPTANCE TEST
21
Behat is an open source
Behavior Driven Development framework
(Source: http://docs.behat.com)
FUNCTIONAL- AND ACCEPTANCE TEST
22
Gherkin is a Business Readable,
Domain Specific Language created
especially for behavior descriptions.
(Source: http://docs.behat.com)
FUNCTIONAL- AND ACCEPTANCE TEST
23
gherkin example
Feature: Some terse yet descriptive text of what is desired
In order to realize a named business value
As an explicit system actor
I want to gain some beneficial outcome which furthers the goal
Additional text...
Scenario: Some determinable business situation
Given some precondition
And some other precondition
When some action by the actor
And some other action
And yet another action
Then some testable outcome is achieved
And something else we can check happens too
Scenario: A different situation
...
(Source: http://docs.behat.com)
FUNCTIONAL- AND ACCEPTANCE TEST
24
Mink is an open source
browser controller/emulator
for web applications
(Source: http://mink.behat.com)
FUNCTIONAL- AND ACCEPTANCE TEST
25
practical example
configure (behat.yml)
default:
extensions:
BehatMinkExtension:
base_url: 'http://example.com'
goutte: ~
install
# mkdir ~/Desktop/Behat-Example
# cd ~/Desktop/Behat-Example
# composer.phar require behat/mink-extension behat/mink-goutte-driver
initialize
# ./vendor/bin/behat --init
FUNCTIONAL- AND ACCEPTANCE TEST
26
mink context
extend FeatureContext.php
...
use BehatGherkinNodeTableNode;

use BehatMinkExtensionContextMinkContext;



/**

* Defines application features from the specific context.

*/

class FeatureContext extends MinkContext implements Context, SnippetAcceptingContext

{

/**

* Initializes context.

...
FUNCTIONAL- AND ACCEPTANCE TEST
27
feature
setup feature
# vim features/repository.feature
repository.feature
Feature: ...
In order to ...
As a ...
I need to be able to ...
Scenario:
Given ...
When ...
Then ...
FUNCTIONAL- AND ACCEPTANCE TEST
28
selenium
start server
# java –jar selenium-server-standalone-2.x.x.jar
extend behat.yml
default:
extensions:
BehatMinkExtension:
base_url: 'http://www.typo3.org'
# goutte: ~
selenium2: ~
install
# composer require behat/mink-selenium2-driver
FUNCTIONAL- AND ACCEPTANCE TEST
29
feature
repository.feature
Feature: TYPO3 repository

In order to provide extensions

As a guest

I should be able to find an extension

Scenario: Finding the extension "extension builder"

Given I am on the homepage

When I follow "Extensions"

And I fill in "q" with "builder"

And I press "Search"

Then I should see "Extension Builder"
FUNCTIONAL- AND ACCEPTANCE TEST
30
using behat / mink within
TYPO3 context
FUNCTIONAL- AND ACCEPTANCE TEST
31
behat-typo3-extension
extending composer.json
add the following lines to your TYPO3_SRC/composer.json:
"require-dev": {
"phpunit/phpunit": "~4.8.0",
"mikey179/vfsStream": "1.6.0",
"behat/behat": "^3.0",
"behat/mink": "^1.7",
"behat/mink-extension": "^2.1",
"behat/mink-goutte-driver": "^1.2",
"behat/mink-selenium2-driver": "^1.3",
"heikohardt/behat-typo3-extension": "^1.0“
},
You need to execute the command: composer update after this change
FUNCTIONAL- AND ACCEPTANCE TEST
32
behat-typo3-extension
environment variables, xdebug (optional)
XDEBUG_CONFIG your ide key
PHP_IDE_CONFIG serverName=servername which is configured in your xdebug configuration
environment variables, behat
TYPO3_PATH_WEB document root of your source TYPO3 instance

BEHAT_TYPO3_DOCROOT document root of your behat TYPO3 instance
BEHAT_TYPO3_DB_HOST host address of your behat database
BEHAT_TYPO3_DB_NAME database of your behat database user
BEHAT_TYPO3_DB_USERNAME username of your behat database user

BEHAT_TYPO3_DB_PASSWORD password of your behat database user
default:

suites:

default:

contexts:

- FeatureContext

- Typo3Context



extensions:

BehatMinkExtension:

base_url: 'http://behat.typo3v62.t3ee.conf'

goutte: ~

selenium2: ~

HeikoHardtBehatTYPO3ExtensionServiceContainerTypo3Extension: ~
FUNCTIONAL- AND ACCEPTANCE TEST
33
behat-typo3-extension
behat.yml
setTYPO3CoreExtensionsToLoad(array)
setTYPO3TestExtensionsToLoad(array)
setTYPO3LocalConfiguration(array)
setTYPO3DatasetToImport(array)
setTYPO3FrontendRootPage( int, array)
setTYPO3CreateDirectories(array)
TYPO3Boot($this, $scope);
FUNCTIONAL- AND ACCEPTANCE TEST
34
behat-typo3-extension
TYPO3 methods
config {

no_cache = 1

uniqueLinkVars = 1

renderCharset = utf-8

metaCharset = utf-8

doctype = html5

removeDefaultJS = external

admPanel = 0

debug = 0

sendCacheHeaders = 0

sys_language_uid = 0

}
FUNCTIONAL- AND ACCEPTANCE TEST
35
behat-typo3-extension
Fixtures::Setup.ts
page = PAGE

page {

typeNum = 0

10 = USER

10 {

userFunc = TYPO3CMSExtbaseCoreBootstrap->run

extensionName = T3eeVotingExample

pluginName = Pi1

vendorName = HeikoHardt

controller = Topic

action = list

}

includeJSlibs.file1 = EXT:t3ee_voting_example/Resources/.../jquery-1.11.3.min.js

includeJS.file2 = EXT:t3ee_voting_example/Resources/.../t3ee_voting_example.min.js

}
FUNCTIONAL- AND ACCEPTANCE TEST
36
behat-typo3-extension
Fixtures::Setup.ts
practical part
t3ee_voting_example
37
questions?
38
Thanks J
DISCLAIMER
The information contained in this presentation are the subject of intellectual property rights and/or copyright, or
confidential information within the meaning of business or trade secrets of the Pixelpark AG and/or its affiliates. It is
intended solely for internal use at the intended receiver and copies may be made for internal purposes only. Any
publication, disclosure to third parties, as well as the application of intellectual property rights and provision with its
own copyright notice is prohibited.
40

More Related Content

What's hot

PHPUnit: from zero to hero
PHPUnit: from zero to heroPHPUnit: from zero to hero
PHPUnit: from zero to hero
Jeremy Cook
 
Test driven development_for_php
Test driven development_for_phpTest driven development_for_php
Test driven development_for_php
Lean Teams Consultancy
 
Python testing using mock and pytest
Python testing using mock and pytestPython testing using mock and pytest
Python testing using mock and pytest
Suraj Deshmukh
 
Testing persistence in PHP with DbUnit
Testing persistence in PHP with DbUnitTesting persistence in PHP with DbUnit
Testing persistence in PHP with DbUnitPeter Wilcsinszky
 
Beginning PHPUnit
Beginning PHPUnitBeginning PHPUnit
Beginning PHPUnitJace Ju
 
Test in action week 2
Test in action   week 2Test in action   week 2
Test in action week 2Yi-Huan Chan
 
EPHPC Webinar Slides: Unit Testing by Arthur Purnama
EPHPC Webinar Slides: Unit Testing by Arthur PurnamaEPHPC Webinar Slides: Unit Testing by Arthur Purnama
EPHPC Webinar Slides: Unit Testing by Arthur PurnamaEnterprise PHP Center
 
Keep your repo clean
Keep your repo cleanKeep your repo clean
Keep your repo clean
Hector Canto
 
Test in action week 4
Test in action   week 4Test in action   week 4
Test in action week 4Yi-Huan Chan
 
DRYing to Monad in Java8
DRYing to Monad in Java8DRYing to Monad in Java8
DRYing to Monad in Java8
Dhaval Dalal
 
(Unit )-Testing for Joomla
(Unit )-Testing for Joomla(Unit )-Testing for Joomla
(Unit )-Testing for Joomla
David Jardin
 
Developing Drizzle Replication Plugins
Developing Drizzle Replication PluginsDeveloping Drizzle Replication Plugins
Developing Drizzle Replication Plugins
Padraig O'Sullivan
 
Test in action – week 1
Test in action – week 1Test in action – week 1
Test in action – week 1Yi-Huan Chan
 
Test in action week 3
Test in action   week 3Test in action   week 3
Test in action week 3Yi-Huan Chan
 
Currying and Partial Function Application (PFA)
Currying and Partial Function Application (PFA)Currying and Partial Function Application (PFA)
Currying and Partial Function Application (PFA)
Dhaval Dalal
 
Unit testing
Unit testingUnit testing
Unit testing
Arthur Purnama
 
20111018 boost and gtest
20111018 boost and gtest20111018 boost and gtest
20111018 boost and gtestWill Shen
 
2010 07-28-testing-zf-apps
2010 07-28-testing-zf-apps2010 07-28-testing-zf-apps
2010 07-28-testing-zf-apps
Venkata Ramana
 

What's hot (20)

PHPUnit: from zero to hero
PHPUnit: from zero to heroPHPUnit: from zero to hero
PHPUnit: from zero to hero
 
Test driven development_for_php
Test driven development_for_phpTest driven development_for_php
Test driven development_for_php
 
Python testing using mock and pytest
Python testing using mock and pytestPython testing using mock and pytest
Python testing using mock and pytest
 
Testing persistence in PHP with DbUnit
Testing persistence in PHP with DbUnitTesting persistence in PHP with DbUnit
Testing persistence in PHP with DbUnit
 
Beginning PHPUnit
Beginning PHPUnitBeginning PHPUnit
Beginning PHPUnit
 
Test in action week 2
Test in action   week 2Test in action   week 2
Test in action week 2
 
EPHPC Webinar Slides: Unit Testing by Arthur Purnama
EPHPC Webinar Slides: Unit Testing by Arthur PurnamaEPHPC Webinar Slides: Unit Testing by Arthur Purnama
EPHPC Webinar Slides: Unit Testing by Arthur Purnama
 
Keep your repo clean
Keep your repo cleanKeep your repo clean
Keep your repo clean
 
Test in action week 4
Test in action   week 4Test in action   week 4
Test in action week 4
 
Clean coding-practices
Clean coding-practicesClean coding-practices
Clean coding-practices
 
DRYing to Monad in Java8
DRYing to Monad in Java8DRYing to Monad in Java8
DRYing to Monad in Java8
 
UPC Testing talk 2
UPC Testing talk 2UPC Testing talk 2
UPC Testing talk 2
 
(Unit )-Testing for Joomla
(Unit )-Testing for Joomla(Unit )-Testing for Joomla
(Unit )-Testing for Joomla
 
Developing Drizzle Replication Plugins
Developing Drizzle Replication PluginsDeveloping Drizzle Replication Plugins
Developing Drizzle Replication Plugins
 
Test in action – week 1
Test in action – week 1Test in action – week 1
Test in action – week 1
 
Test in action week 3
Test in action   week 3Test in action   week 3
Test in action week 3
 
Currying and Partial Function Application (PFA)
Currying and Partial Function Application (PFA)Currying and Partial Function Application (PFA)
Currying and Partial Function Application (PFA)
 
Unit testing
Unit testingUnit testing
Unit testing
 
20111018 boost and gtest
20111018 boost and gtest20111018 boost and gtest
20111018 boost and gtest
 
2010 07-28-testing-zf-apps
2010 07-28-testing-zf-apps2010 07-28-testing-zf-apps
2010 07-28-testing-zf-apps
 

Similar to Testing the frontend

Modern Python Testing
Modern Python TestingModern Python Testing
Modern Python Testing
Alexander Loechel
 
Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01Tony Frame
 
Effective testing with pytest
Effective testing with pytestEffective testing with pytest
Effective testing with pytest
Hector Canto
 
[xp2013] Narrow Down What to Test
[xp2013] Narrow Down What to Test[xp2013] Narrow Down What to Test
[xp2013] Narrow Down What to Test
Zsolt Fabok
 
Effizientere WordPress-Plugin-Entwicklung mit Softwaretests
Effizientere WordPress-Plugin-Entwicklung mit SoftwaretestsEffizientere WordPress-Plugin-Entwicklung mit Softwaretests
Effizientere WordPress-Plugin-Entwicklung mit Softwaretests
DECK36
 
Testing Your Application On Google App Engine
Testing Your Application On Google App EngineTesting Your Application On Google App Engine
Testing Your Application On Google App Engine
IndicThreads
 
Testing your application on Google App Engine
Testing your application on Google App EngineTesting your application on Google App Engine
Testing your application on Google App Engine
Inphina Technologies
 
Workshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingWorkshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testing
Visual Engineering
 
Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12
Michelangelo van Dam
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e bigAndy Peterson
 
websphere cast iron labs
 websphere cast iron labs websphere cast iron labs
websphere cast iron labs
AMIT KUMAR
 
Introduction to Google App Engine with Python
Introduction to Google App Engine with PythonIntroduction to Google App Engine with Python
Introduction to Google App Engine with Python
Brian Lyttle
 
Organizing Machine Learning Projects - Repository Organization
Organizing Machine Learning Projects - Repository OrganizationOrganizing Machine Learning Projects - Repository Organization
Organizing Machine Learning Projects - Repository Organization
Hao-Wen (Herman) Dong
 
Integration Testing With ScalaTest and MongoDB
Integration Testing With ScalaTest and MongoDBIntegration Testing With ScalaTest and MongoDB
Integration Testing With ScalaTest and MongoDB
Michal Bigos
 
UI Testing
UI TestingUI Testing
UI Testing
Josh Black
 
Testing for fun in production Into The Box 2018
Testing for fun in production Into The Box 2018Testing for fun in production Into The Box 2018
Testing for fun in production Into The Box 2018
Ortus Solutions, Corp
 
Apache Calcite Tutorial - BOSS 21
Apache Calcite Tutorial - BOSS 21Apache Calcite Tutorial - BOSS 21
Apache Calcite Tutorial - BOSS 21
Stamatis Zampetakis
 
Data Seeding via Parameterized API Requests
Data Seeding via Parameterized API RequestsData Seeding via Parameterized API Requests
Data Seeding via Parameterized API Requests
RapidValue
 
Working Effectively With Legacy Perl Code
Working Effectively With Legacy Perl CodeWorking Effectively With Legacy Perl Code
Working Effectively With Legacy Perl Codeerikmsp
 
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
GlobalLogic Ukraine
 

Similar to Testing the frontend (20)

Modern Python Testing
Modern Python TestingModern Python Testing
Modern Python Testing
 
Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01
 
Effective testing with pytest
Effective testing with pytestEffective testing with pytest
Effective testing with pytest
 
[xp2013] Narrow Down What to Test
[xp2013] Narrow Down What to Test[xp2013] Narrow Down What to Test
[xp2013] Narrow Down What to Test
 
Effizientere WordPress-Plugin-Entwicklung mit Softwaretests
Effizientere WordPress-Plugin-Entwicklung mit SoftwaretestsEffizientere WordPress-Plugin-Entwicklung mit Softwaretests
Effizientere WordPress-Plugin-Entwicklung mit Softwaretests
 
Testing Your Application On Google App Engine
Testing Your Application On Google App EngineTesting Your Application On Google App Engine
Testing Your Application On Google App Engine
 
Testing your application on Google App Engine
Testing your application on Google App EngineTesting your application on Google App Engine
Testing your application on Google App Engine
 
Workshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingWorkshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testing
 
Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e big
 
websphere cast iron labs
 websphere cast iron labs websphere cast iron labs
websphere cast iron labs
 
Introduction to Google App Engine with Python
Introduction to Google App Engine with PythonIntroduction to Google App Engine with Python
Introduction to Google App Engine with Python
 
Organizing Machine Learning Projects - Repository Organization
Organizing Machine Learning Projects - Repository OrganizationOrganizing Machine Learning Projects - Repository Organization
Organizing Machine Learning Projects - Repository Organization
 
Integration Testing With ScalaTest and MongoDB
Integration Testing With ScalaTest and MongoDBIntegration Testing With ScalaTest and MongoDB
Integration Testing With ScalaTest and MongoDB
 
UI Testing
UI TestingUI Testing
UI Testing
 
Testing for fun in production Into The Box 2018
Testing for fun in production Into The Box 2018Testing for fun in production Into The Box 2018
Testing for fun in production Into The Box 2018
 
Apache Calcite Tutorial - BOSS 21
Apache Calcite Tutorial - BOSS 21Apache Calcite Tutorial - BOSS 21
Apache Calcite Tutorial - BOSS 21
 
Data Seeding via Parameterized API Requests
Data Seeding via Parameterized API RequestsData Seeding via Parameterized API Requests
Data Seeding via Parameterized API Requests
 
Working Effectively With Legacy Perl Code
Working Effectively With Legacy Perl CodeWorking Effectively With Legacy Perl Code
Working Effectively With Legacy Perl Code
 
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
 

Recently uploaded

BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 

Recently uploaded (20)

BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 

Testing the frontend

  • 1. Testing the frontend, a brief introduction to the main techniques and tools. Cluj-Napoca, 13th November 2015
  • 2. ABOUT 2 •  senior it developer @ publicis pixelpark •  experience since 1998 •  supporting: •  processes •  infrastructure •  quality assurance heiko hardt
  • 4. MISSION voting module The user should be able to vote on a topic should enter a name and an email address for voting should vote once a topic The topic should be maintained in a protected frontend area The results should be shown in a protected frontend area 4
  • 5. MISSION voting module, scribble 5 buttons Please enter your name and Email address Email: Name: NOYES BACK Oooops an error... voting Well done... What do you think about ... ? VOTE Yes 1023 No 536 teaser message(s) topic formresult
  • 7. UNIT- AND INTEGRATION TESTS 7 Jasmine is a behavior-driven development framework for testing JavaScript code. (Source: http://jasmine.github.io)
  • 8. UNIT- AND INTEGRATION TESTS 8 jasmine, filetype and structure spec(s)? it('should give me a brief introduction', function() {
 // expect ...
 }); *.spec.js? In jasmine the tests are written in a *spec.js file. I prefer using the „source-file-name“.spec.js src/t3ee_voting_example.js = spec/t3ee_voting_example.spec.js suite(s)? describe('This awesome session', function() {
 // should be ...
 });
  • 9. UNIT- AND INTEGRATION TESTS 9 jasmine, spec and suite example spec/t3ee_voting_example.spec.js // suite describe('This awesome session', function() {
 // spec
 it('should give me a brief introduction', function() { 
 // matcher... 
 });
 
 }); Results in: This awesome session should give me a brief introduction J
  • 10. UNIT- AND INTEGRATION TESTS 10 jasmine, expectation ... toBe or not.toBet not.toBe() By using „not“ you are able to test against a negative/reverted „given“ expect(argument).not.toBe(given) expect(false).not.toBe(true) expectation All tests are written in expectations. You expect that an „argument or obj or ...“ will „match“ expect(argument).matcher toBe() The matcher „toBe“ test if the „argument“ is the same like „given“ expect(argument).toBe(given) expect(1+2).toBe(3)
  • 11. UNIT- AND INTEGRATION TESTS 11 jasmine, expectation ... spy toBeCalledWith(argument) document.getElementsByClassName(„tester“) expect(window.document, getElementsByClassName).toBeCalledWidth(„tester“) spyOn(object, function) spyOn(window.document, "getElementsByClassName"); toBeCalled() document.getElementsByClassName(„tester“) expect(window.document, getElementsByClassName).toBeCalled()
  • 13. UNIT- AND INTEGRATION TESTS 13 karma Karma - Spectacular Test Runner for Javascript
  • 14. PRACTICAL PART 14 karma setup intellij / phpstorm / ... Menu -> Run -> Edit Configuration Add (+) Karma Setup Configuration file to karma.conf.js setup karma via node package manager # npm init # npm install karma –save-dev # node_modules/karma/bin/karma init start and run # node_modules/karma/bin/karma start # node_modules/karma/bin/karma run
  • 15. PRACTICAL PART 15 karma - code coverage edit karma.conf.js: reporter reporters: ['progress', 'coverage'], install karma-coverage via node package manager # npm install karma-coverage --save-dev edit karma.conf.js: preprocessor preprocessors: {
 'src/*.js': ['coverage']
 },

  • 16. UNIT- AND INTEGRATION TESTS 16 grunt grunt, a javascript task runner
  • 17. PRACTICAL PART 17 grunt install grunt # npm install grunt --save-dev # npm install grunt-cli --save-dev install uglify # npm install grunt-contrib-uglify --save-dev
  • 18. PRACTICAL PART 18 grunt Gruntfile.js module.exports = function(grunt) { grunt.initConfig({ uglify: { options: { beautify: { width: 80, beautify: true }, compress: { global_defs: { "jasmine" : false }, dead_code: true } }, my_target: { files:{'src/t3ee_voting_example.min.js’:['src/t3ee_voting_example.js’]}} } }); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.registerTask('default', ['uglify']); };
  • 21. FUNCTIONAL- AND ACCEPTANCE TEST 21 Behat is an open source Behavior Driven Development framework (Source: http://docs.behat.com)
  • 22. FUNCTIONAL- AND ACCEPTANCE TEST 22 Gherkin is a Business Readable, Domain Specific Language created especially for behavior descriptions. (Source: http://docs.behat.com)
  • 23. FUNCTIONAL- AND ACCEPTANCE TEST 23 gherkin example Feature: Some terse yet descriptive text of what is desired In order to realize a named business value As an explicit system actor I want to gain some beneficial outcome which furthers the goal Additional text... Scenario: Some determinable business situation Given some precondition And some other precondition When some action by the actor And some other action And yet another action Then some testable outcome is achieved And something else we can check happens too Scenario: A different situation ... (Source: http://docs.behat.com)
  • 24. FUNCTIONAL- AND ACCEPTANCE TEST 24 Mink is an open source browser controller/emulator for web applications (Source: http://mink.behat.com)
  • 25. FUNCTIONAL- AND ACCEPTANCE TEST 25 practical example configure (behat.yml) default: extensions: BehatMinkExtension: base_url: 'http://example.com' goutte: ~ install # mkdir ~/Desktop/Behat-Example # cd ~/Desktop/Behat-Example # composer.phar require behat/mink-extension behat/mink-goutte-driver initialize # ./vendor/bin/behat --init
  • 26. FUNCTIONAL- AND ACCEPTANCE TEST 26 mink context extend FeatureContext.php ... use BehatGherkinNodeTableNode;
 use BehatMinkExtensionContextMinkContext;
 
 /**
 * Defines application features from the specific context.
 */
 class FeatureContext extends MinkContext implements Context, SnippetAcceptingContext
 {
 /**
 * Initializes context.
 ...
  • 27. FUNCTIONAL- AND ACCEPTANCE TEST 27 feature setup feature # vim features/repository.feature repository.feature Feature: ... In order to ... As a ... I need to be able to ... Scenario: Given ... When ... Then ...
  • 28. FUNCTIONAL- AND ACCEPTANCE TEST 28 selenium start server # java –jar selenium-server-standalone-2.x.x.jar extend behat.yml default: extensions: BehatMinkExtension: base_url: 'http://www.typo3.org' # goutte: ~ selenium2: ~ install # composer require behat/mink-selenium2-driver
  • 29. FUNCTIONAL- AND ACCEPTANCE TEST 29 feature repository.feature Feature: TYPO3 repository
 In order to provide extensions
 As a guest
 I should be able to find an extension
 Scenario: Finding the extension "extension builder"
 Given I am on the homepage
 When I follow "Extensions"
 And I fill in "q" with "builder"
 And I press "Search"
 Then I should see "Extension Builder"
  • 30. FUNCTIONAL- AND ACCEPTANCE TEST 30 using behat / mink within TYPO3 context
  • 31. FUNCTIONAL- AND ACCEPTANCE TEST 31 behat-typo3-extension extending composer.json add the following lines to your TYPO3_SRC/composer.json: "require-dev": { "phpunit/phpunit": "~4.8.0", "mikey179/vfsStream": "1.6.0", "behat/behat": "^3.0", "behat/mink": "^1.7", "behat/mink-extension": "^2.1", "behat/mink-goutte-driver": "^1.2", "behat/mink-selenium2-driver": "^1.3", "heikohardt/behat-typo3-extension": "^1.0“ }, You need to execute the command: composer update after this change
  • 32. FUNCTIONAL- AND ACCEPTANCE TEST 32 behat-typo3-extension environment variables, xdebug (optional) XDEBUG_CONFIG your ide key PHP_IDE_CONFIG serverName=servername which is configured in your xdebug configuration environment variables, behat TYPO3_PATH_WEB document root of your source TYPO3 instance
 BEHAT_TYPO3_DOCROOT document root of your behat TYPO3 instance BEHAT_TYPO3_DB_HOST host address of your behat database BEHAT_TYPO3_DB_NAME database of your behat database user BEHAT_TYPO3_DB_USERNAME username of your behat database user
 BEHAT_TYPO3_DB_PASSWORD password of your behat database user
  • 33. default:
 suites:
 default:
 contexts:
 - FeatureContext
 - Typo3Context
 
 extensions:
 BehatMinkExtension:
 base_url: 'http://behat.typo3v62.t3ee.conf'
 goutte: ~
 selenium2: ~
 HeikoHardtBehatTYPO3ExtensionServiceContainerTypo3Extension: ~ FUNCTIONAL- AND ACCEPTANCE TEST 33 behat-typo3-extension behat.yml
  • 35. config {
 no_cache = 1
 uniqueLinkVars = 1
 renderCharset = utf-8
 metaCharset = utf-8
 doctype = html5
 removeDefaultJS = external
 admPanel = 0
 debug = 0
 sendCacheHeaders = 0
 sys_language_uid = 0
 } FUNCTIONAL- AND ACCEPTANCE TEST 35 behat-typo3-extension Fixtures::Setup.ts
  • 36. page = PAGE
 page {
 typeNum = 0
 10 = USER
 10 {
 userFunc = TYPO3CMSExtbaseCoreBootstrap->run
 extensionName = T3eeVotingExample
 pluginName = Pi1
 vendorName = HeikoHardt
 controller = Topic
 action = list
 }
 includeJSlibs.file1 = EXT:t3ee_voting_example/Resources/.../jquery-1.11.3.min.js
 includeJS.file2 = EXT:t3ee_voting_example/Resources/.../t3ee_voting_example.min.js
 } FUNCTIONAL- AND ACCEPTANCE TEST 36 behat-typo3-extension Fixtures::Setup.ts
  • 40. DISCLAIMER The information contained in this presentation are the subject of intellectual property rights and/or copyright, or confidential information within the meaning of business or trade secrets of the Pixelpark AG and/or its affiliates. It is intended solely for internal use at the intended receiver and copies may be made for internal purposes only. Any publication, disclosure to third parties, as well as the application of intellectual property rights and provision with its own copyright notice is prohibited. 40

Editor's Notes

  1. ----- Besprechungsnotizen (11.11.15 11:18) ----- labeled as brief introduction do my best keeping it as simple as possible