O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.
Text
Introducing Codeception
(TDD)—>Test Driven Development
Agenda
Presentation of Speaker/ Company
Presentation of Codeception
Presentation of Tests Types
Demonstration & Hands-on
B...
Who the hell am I ?
Batard Florent (28 years old)(Shenril)
Twitter: @shenril
Facebook: Florent Btd
Security Engineer (Ethi...
Who the hell am I ?
Batard Florent (28 years old)(Shenril)
Twitter: @shenril
Facebook: Florent Btd
Security Engineer (Ethi...
Who the hell am I ?
Batard Florent (28 years old)(Shenril)
Twitter: @shenril
Facebook: Florent Btd
Security Engineer (Ethi...
Who the hell am I ?
Batard Florent (28 years old)(Shenril)
Twitter: @shenril
Facebook: Florent Btd
Security Engineer (Ethi...
Who the hell am I ?
Batard Florent (28 years old)(Shenril)
Twitter: @shenril
Facebook: Florent Btd
Security Engineer (Ethi...
Who the hell am I ?
Batard Florent (28 years old)(Shenril)
Twitter: @shenril
Facebook: Florent Btd
Security Engineer (Ethi...
Who the hell am I ?
Batard Florent (28 years old)(Shenril)
Twitter: @shenril
Facebook: Florent Btd
Security Engineer (Ethi...
Why do i speak here?
Worked for:
W3C in Sophia Antipolis
U.N (Security Consultant)
Private Banking
Television
Did conferen...
Why do i speak here?
Worked for:
W3C in Sophia Antipolis
U.N (Security Consultant)
Private Banking
Television
Did conferen...
Why do i speak here?
Worked for:
W3C in Sophia Antipolis
U.N (Security Consultant)
Private Banking
Television
Did conferen...
Why do i speak here?
Worked for:
W3C in Sophia Antipolis
U.N (Security Consultant)
Private Banking
Television
Did conferen...
Who do I work for?
Cook+biz
Awesome Team
Awesome Challenges
Who do I work for?
Cook+biz
Awesome Team
Awesome Challenges
Who do I work for?
Cook+biz
Awesome Team
Awesome Challenges
Why Testing?
Why should I test my code ?
Reduce False assumptions -> If you rely on assumptions it will surely fail…
Valid...
CodeCeption(1)
http://codeception.com/ (English)
Test Framework
Acceptance Tests
Functional Tests
Unit Tests
Easy
To read
...
CodeCeption(2)
BDD-style scenario-driver tests
WebServices tests (SOAP/REST/XML-RPC)
Generates reports(HTML/XML/JSON)
Lara...
What does it look like?
<?php
$I = new AcceptanceTester($scenario);
$I->wantTo('create wiki page');
$I->amOnPage('/');
$I-...
Different tests types
Acceptance
Tests
Functional
Tests
Unit Tests
Yii2 BackendFrontend
Browser
Selenium
PhantomJS
HTML
HT...
Different tests types
Acceptance
Tests
Functional
Tests
Unit Tests
Yii2 BackendFrontend
Browser
Selenium
PhantomJS
HTML
HT...
Different tests types
Acceptance
Tests
Functional
Tests
Unit Tests
Yii2 BackendFrontend
Browser
Selenium
PhantomJS
HTML
HT...
Different tests types
Acceptance
Tests
Functional
Tests
Unit Tests
Yii2 BackendFrontend
Browser
Selenium
PhantomJS
HTML
HT...
Different tests types
Acceptance
Tests
Functional
Tests
Unit Tests
Yii2 BackendFrontend
Browser
Selenium
PhantomJS
HTML
HT...
Different tests types
Acceptance
Tests
Functional
Tests
Unit Tests
Yii2 BackendFrontend
Browser
Selenium
PhantomJS
HTML
HT...
Different tests types
Acceptance
Tests
Functional
Tests
Unit Tests
Yii2 BackendFrontend
Browser
Selenium
PhantomJS
HTML
HT...
Acceptance Tests
Enable to do request and interact with the DOM
Use a fake browser to perform the queries
Can click and fil...
Functional Tests
Same as Acceptance test but does not use a browser
engine
Can be plugged with the framework to access int...
Unit Tests
Used to test functions
Can be plugged with the framework to access internal functions and properties (Models, V...
Install on all platforms
Mac OSX:
brew update && brew install homebrew/php/codeception
Linux:
wget http://codeception.com/...
Getting ready
BootStrap
>codecept bootstrap
>codecept generate:cept acceptance Validation
Edit the configuration file : test...
Let’s get the party started
>codecept run
>codecept run —debug
Bonus
>codecept generate:scenarios acceptance //English ver...
Demo Time !!!!!
> Let’s test PHP conference Kansai website !
Best practices
1. Run tests on your vagrant -> GIT push ONLY when tests pass
2. Deploy on test server -> Validate tests on...
References
Installation : http://codeception.com/install
Acceptance Tests : http://codeception.com/docs/04-AcceptanceTests...
Questions & Answers
Do you have any questions?
Codeception Testing Framework -- English #phpkansai
Próximos SlideShares
Carregando em…5
×

3

Compartilhar

Baixar para ler offline

Codeception Testing Framework -- English #phpkansai

Baixar para ler offline

Codeception Testing Framework in PHP
Finally unpainful testing in php

Livros relacionados

Gratuito durante 30 dias do Scribd

Ver tudo

Audiolivros relacionados

Gratuito durante 30 dias do Scribd

Ver tudo

Codeception Testing Framework -- English #phpkansai

  1. 1. Text Introducing Codeception (TDD)—>Test Driven Development
  2. 2. Agenda Presentation of Speaker/ Company Presentation of Codeception Presentation of Tests Types Demonstration & Hands-on Best Practices References Q & A @phpcon_kansai
  3. 3. Who the hell am I ? Batard Florent (28 years old)(Shenril) Twitter: @shenril Facebook: Florent Btd Security Engineer (Ethical Hacker) French Globe Trotter Lived in France,UK,Switzerland,U.S,Japan Fan of Japan and especially Kansai area and people Style learning Japanese….
  4. 4. Who the hell am I ? Batard Florent (28 years old)(Shenril) Twitter: @shenril Facebook: Florent Btd Security Engineer (Ethical Hacker) French Globe Trotter Lived in France,UK,Switzerland,U.S,Japan Fan of Japan and especially Kansai area and people Style learning Japanese….
  5. 5. Who the hell am I ? Batard Florent (28 years old)(Shenril) Twitter: @shenril Facebook: Florent Btd Security Engineer (Ethical Hacker) French Globe Trotter Lived in France,UK,Switzerland,U.S,Japan Fan of Japan and especially Kansai area and people Style learning Japanese….
  6. 6. Who the hell am I ? Batard Florent (28 years old)(Shenril) Twitter: @shenril Facebook: Florent Btd Security Engineer (Ethical Hacker) French Globe Trotter Lived in France,UK,Switzerland,U.S,Japan Fan of Japan and especially Kansai area and people Style learning Japanese….
  7. 7. Who the hell am I ? Batard Florent (28 years old)(Shenril) Twitter: @shenril Facebook: Florent Btd Security Engineer (Ethical Hacker) French Globe Trotter Lived in France,UK,Switzerland,U.S,Japan Fan of Japan and especially Kansai area and people Style learning Japanese….
  8. 8. Who the hell am I ? Batard Florent (28 years old)(Shenril) Twitter: @shenril Facebook: Florent Btd Security Engineer (Ethical Hacker) French Globe Trotter Lived in France,UK,Switzerland,U.S,Japan Fan of Japan and especially Kansai area and people Style learning Japanese….
  9. 9. Who the hell am I ? Batard Florent (28 years old)(Shenril) Twitter: @shenril Facebook: Florent Btd Security Engineer (Ethical Hacker) French Globe Trotter Lived in France,UK,Switzerland,U.S,Japan Fan of Japan and especially Kansai area and people Style learning Japanese….
  10. 10. Why do i speak here? Worked for: W3C in Sophia Antipolis U.N (Security Consultant) Private Banking Television Did conferences in Europe Mainly Security (Youtube) (sorry french and english only) Active Member of OWASP (Web Security Project) Web Developer for the past 10 years Interested in DevOps ,Servers, Infrastructure, Artificial Intelligence Learning Animal
  11. 11. Why do i speak here? Worked for: W3C in Sophia Antipolis U.N (Security Consultant) Private Banking Television Did conferences in Europe Mainly Security (Youtube) (sorry french and english only) Active Member of OWASP (Web Security Project) Web Developer for the past 10 years Interested in DevOps ,Servers, Infrastructure, Artificial Intelligence Learning Animal
  12. 12. Why do i speak here? Worked for: W3C in Sophia Antipolis U.N (Security Consultant) Private Banking Television Did conferences in Europe Mainly Security (Youtube) (sorry french and english only) Active Member of OWASP (Web Security Project) Web Developer for the past 10 years Interested in DevOps ,Servers, Infrastructure, Artificial Intelligence Learning Animal
  13. 13. Why do i speak here? Worked for: W3C in Sophia Antipolis U.N (Security Consultant) Private Banking Television Did conferences in Europe Mainly Security (Youtube) (sorry french and english only) Active Member of OWASP (Web Security Project) Web Developer for the past 10 years Interested in DevOps ,Servers, Infrastructure, Artificial Intelligence Learning Animal
  14. 14. Who do I work for? Cook+biz Awesome Team Awesome Challenges
  15. 15. Who do I work for? Cook+biz Awesome Team Awesome Challenges
  16. 16. Who do I work for? Cook+biz Awesome Team Awesome Challenges
  17. 17. Why Testing? Why should I test my code ? Reduce False assumptions -> If you rely on assumptions it will surely fail… Validate that there is no regression Make sure the code runs as expected Test limit values (security,big data) Automate repetitive tasks -> Good developers are lazy developers!!! It makes debugging/correction so much easier But… Often developers finds it hard to write Too long too run Doesn’t correspond to business logic/behaviour/user scenario
  18. 18. CodeCeption(1) http://codeception.com/ (English) Test Framework Acceptance Tests Functional Tests Unit Tests Easy To read To write To debug Natively handles PHPUnit -> standard
  19. 19. CodeCeption(2) BDD-style scenario-driver tests WebServices tests (SOAP/REST/XML-RPC) Generates reports(HTML/XML/JSON) Laravel/Zend/Phalcon/Yii2/Symfony/Composer modules - > No excuse! Integration with continuous deployment (Jenkins/Bamboo) Can be used along with Selenium2 and PhantomJS for advanced tests
  20. 20. What does it look like? <?php $I = new AcceptanceTester($scenario); $I->wantTo('create wiki page'); $I->amOnPage('/'); $I->click('Pages'); $I->click('New'); $I->see('New Page'); $I->fillField('title', 'Hobbit'); $I->fillField('body', 'By Peter Jackson'); $I->click('Save'); $I->see('page created'); // notice generated $I->see('Hobbit','h1'); // head of page of is our title $I->seeInCurrentUrl('pages/hobbit'); $I->seeInDatabase('pages', array('title' => ‘Hobbit')); ?>
  21. 21. Different tests types Acceptance Tests Functional Tests Unit Tests Yii2 BackendFrontend Browser Selenium PhantomJS HTML HTML $_GET,$_POST, $_REQUEST Yii2 Module Backend
  22. 22. Different tests types Acceptance Tests Functional Tests Unit Tests Yii2 BackendFrontend Browser Selenium PhantomJS HTML HTML $_GET,$_POST, $_REQUEST Yii2 Module Backend
  23. 23. Different tests types Acceptance Tests Functional Tests Unit Tests Yii2 BackendFrontend Browser Selenium PhantomJS HTML HTML $_GET,$_POST, $_REQUEST Yii2 Module Backend User Scenario
  24. 24. Different tests types Acceptance Tests Functional Tests Unit Tests Yii2 BackendFrontend Browser Selenium PhantomJS HTML HTML $_GET,$_POST, $_REQUEST Yii2 Module Backend User Scenario
  25. 25. Different tests types Acceptance Tests Functional Tests Unit Tests Yii2 BackendFrontend Browser Selenium PhantomJS HTML HTML $_GET,$_POST, $_REQUEST Yii2 Module Backend User Scenario Developer Scenario
  26. 26. Different tests types Acceptance Tests Functional Tests Unit Tests Yii2 BackendFrontend Browser Selenium PhantomJS HTML HTML $_GET,$_POST, $_REQUEST Yii2 Module Backend User Scenario Developer Scenario
  27. 27. Different tests types Acceptance Tests Functional Tests Unit Tests Yii2 BackendFrontend Browser Selenium PhantomJS HTML HTML $_GET,$_POST, $_REQUEST Yii2 Module Backend User Scenario Developer Scenario Function Testing
  28. 28. Acceptance Tests Enable to do request and interact with the DOM Use a fake browser to perform the queries Can click and fill forms Can be plugged with Selenium/PhantomJS to interact with JavaScript and screenshots Slowest tests to run
  29. 29. Functional Tests Same as Acceptance test but does not use a browser engine Can be plugged with the framework to access internal functions and properties (Models, validation) Use $_REQUEST, $_POST and $_GET Faster No DOM interaction (JS/Ajax/Events)
  30. 30. Unit Tests Used to test functions Can be plugged with the framework to access internal functions and properties (Models, Validation) Fastest Difficult to use in MVC Not readable by Humans public function testValidation() { $user = User::create(); $user->username = null; $this->assertFalse($user->validate(['username'])); $user->username = 'toolooooongnaaaaaaameeee'; $this->assertFalse($user->validate(['username'])); $user->username = 'davert'; $this->assertTrue($user->validate(['username'])); }
  31. 31. Install on all platforms Mac OSX: brew update && brew install homebrew/php/codeception Linux: wget http://codeception.com/codecept.phar . php codecept.phar bootstrap Windows: php composer.phar global require “codeception/codeception:*” Composer/ PhpStorm: php composer.phar require “codeception/codeception:*”
  32. 32. Getting ready BootStrap >codecept bootstrap >codecept generate:cept acceptance Validation Edit the configuration file : tests/acceptance.suite.yml class_name: AcceptanceTester modules: enabled: - PhpBrowser - AcceptanceHelper config: PhpBrowser: url: ‘http://conference.kphpug.jp/2015/’
  33. 33. Let’s get the party started >codecept run >codecept run —debug Bonus >codecept generate:scenarios acceptance //English version >codecept console acceptance //Interactive console >codecept run —debug —env test
  34. 34. Demo Time !!!!! > Let’s test PHP conference Kansai website !
  35. 35. Best practices 1. Run tests on your vagrant -> GIT push ONLY when tests pass 2. Deploy on test server -> Validate tests on test server 3. Deploy on production ONLY if tests pass on test server 4. NEVER run on production ! NEVER!!! 1. It creates new entries and change Database 2. Add load on the production server 3. Need new set of tests/monitoring on production
  36. 36. References Installation : http://codeception.com/install Acceptance Tests : http://codeception.com/docs/04-AcceptanceTests Yii2 module : http://codeception.com/docs/modules/Yii2 WebDriver : http://codeception.com/docs/modules/WebDriver Yii2 Database Faker : http://qiita.com/tanakahisateru/items/ c4d39cc77a71067ed658 Other tools PHPUnit Framework(Difficult) phpspec (Specification & Unit Testing) Pure Selenium/PhantomJS (Harder integration) Mink (Browser Controlling, slow,harder integration)
  37. 37. Questions & Answers Do you have any questions?
  • KenichiMukai

    Jun. 5, 2015
  • ssuser6d17aa

    May. 31, 2015
  • tomoyukisugita

    May. 31, 2015

Codeception Testing Framework in PHP Finally unpainful testing in php

Vistos

Vistos totais

3.501

No Slideshare

0

De incorporações

0

Número de incorporações

73

Ações

Baixados

9

Compartilhados

0

Comentários

0

Curtir

3

×