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.

Mykhailo Bodnarchuk "The history of the Codeception project"

41 visualizações

Publicada em

Codeception is a popular framework for all kind of testing. It helps you to find a suitable level of testing and start writing tests in a pleasant and elegant way. This year a new major version of Codeception was released with new features to improve the testing experience.

What stands behind this? Let's hear the story of Michael Bodnarchuk, PHP developer who started Codeception 7 years ago, and his journey to testing. What he learned by maintaining a testing framework and working as a test consultant nowadays.

Publicada em: Tecnologia
  • Seja o primeiro a comentar

  • Seja a primeira pessoa a gostar disto

Mykhailo Bodnarchuk "The history of the Codeception project"

  1. 1. ABOUT MEABOUT ME Michael Bodnarchuk @davert Lead developer of Codeception Testing Framework Also author of CodeceptJS, Robo and others Consultant @ Web developer from Kyiv, Ukraine SDCLabs
  2. 2. CONFERENCE SPEAKERCONFERENCE SPEAKER
  3. 3. TESTING IN PHPTESTING IN PHP
  4. 4. UGLY PASTUGLY PAST <div id="page"> <div id="header" role="banner"> <div id="headerimg"> <h1><a href="<?php echo home_url(); ?>/"> <?php bloginfo('name'); ?></a> </h1> <div class="description"> <?php bloginfo('description'); ?> </div> </div> </div> <hr /> How would we test this?
  5. 5. ELEGANT MODERNITYELEGANT MODERNITY import React from 'react'; export default React.createClass({ render() { return ( <div className='container'> <Header title={this.props.title} link={this.props.home}> <div className="description"> {this.props.description} </div> </Header> {this.props.children} </div> ); } How would we test this?
  6. 6. EVOLUTION OF PHPEVOLUTION OF PHP PHP was a templating language Business logic in C MiniSQL/MySQL - storage Commons - CMSes/Frameworks
  7. 7. UNIT TESTS?UNIT TESTS? how? is PHP designed for unit testing? mocks? is PHP designed for long run?
  8. 8. TOOL: PHPUNITTOOL: PHPUNIT <?php protected function setUp() { $this->ba = new BankAccount; } public function testBalanceCannotBecomeNegative() { try { $this->ba->withdrawMoney(1); } catch (BankAccountException $e) { $this->assertEquals(0, $this->ba->getBalance()); return; } $this->fail();
  9. 9. ACCEPTANCE TESTSACCEPTANCE TESTS How to test interaction with application How to test controllers and database How to run this?
  10. 10. TOOL: BEHATTOOL: BEHAT Given there is a "Sith Lord Lightsaber", which costs £5 When there is a "Sith Lord Lightsaber", which costs £10 Then there is an 'Anakin Lightsaber', which costs £10 And there is a Lightsaber, which costs £2 But there is a Lightsaber, which costs £25
  11. 11. HOW TO TEST PHPHOW TO TEST PHP APPLICATION?APPLICATION? when it's 2011
  12. 12. MY STORY (2011)MY STORY (2011) Symfony1 project 2 developers framework-level functional tests lime testing framework tests saved our lives no one understood them
  13. 13. MY VISIONMY VISION $I = new TestGuy(); $I->amOnPage('/register'); $I->fillField('login', 'davert'); $I->fillField('password', '123345'); $I->fillField('password_confirmation', '123345'); $I->click('Register'); $I->see('Hello, Davert');
  14. 14. TESTGUY 1.0TESTGUY 1.0 (original title) symfony1 plugin alternative to Behat+Mink
  15. 15. MY STORY (2012)MY STORY (2012) Project failed symfony1 stopped development Alternative frameworks: Zend, Yii, Symfony 2 but what about tests?
  16. 16. CODECEPTION 1.0CODECEPTION 1.0 Symfony components PHPUnit wrapper Modules => Actors Code Generation Suites Cept Self tests?
  17. 17. MARKETINGMARKETING Post on habr.ru reddit.com/r/php Comments in others post Early adopters Conferences
  18. 18. MY STORY (2013-2016)MY STORY (2013-2016) Golden Age Sponsorship by Rebilly & 2Amigos Codeception = Full time job Getting traction and stability
  19. 19. WHAT I LEARNEDWHAT I LEARNED Developers do not test Testing is not TDD or BDD Tests should cover application internally & externally Developers are afraid to change code to not break code Functional tests are the most efficient
  20. 20. CODECEPTION TODAYCODECEPTION TODAY All major frameworks supported Custom modules (over 10) phpunit wrapper (5.0-8.0) Community modules/extensions
  21. 21. ELEGANT MODERNITYELEGANT MODERNITY <?php class Scanner { protected $url; protected $httpClient; public function __construct(HttpClient $httpClient, string $url) { $this->httpClient = $httpClient; $this->urls = $url; } public function isInvalidUrl() : bool { try { $statusCode = $this->getStatusCodeForUrl($url); i $
  22. 22. EVOLUTION OF PHPEVOLUTION OF PHP Business Logic in PHP No templating SOLID principles Depdency Management via Composer
  23. 23. HOW WOULD WE TEST THIS?HOW WOULD WE TEST THIS? unit tests integration tests functional (framework) acceptance (webserver-browser) => Codeception
  24. 24. CODECEPTION 3.0CODECEPTION 3.0
  25. 25. PHPUNIT INTEGATIONPHPUNIT INTEGATION PHPUnit 6.0-8.0 PHPUnit tests compatible Codecoverage Reports Assertions
  26. 26. PHPUNIT COMPATIBILITYPHPUNIT COMPATIBILITY
  27. 27. HOA CONSOLEHOA CONSOLE $I->pause(); Interactive REPL [Live Demo]
  28. 28. CODE GENERATIONCODE GENERATION Multiple Inheritance Auto Rebuilds Step Decorators loggers events conditional assertions tryTo retry
  29. 29. MODULESMODULES PhpBrowser WebDriver Symfony/Laravel REST Db
  30. 30. WHEN PHP IS NOT ENOUGH?WHEN PHP IS NOT ENOUGH? JS Testing Browser Testing JSON Wire WebDriver Protocol Mobile Testing native solutions Appium
  31. 31. WHAT CAN WE DO?WHAT CAN WE DO? ==> CodeceptJS codecept.io
  32. 32. CodeceptJS I.amOnPage('https://bugira.app/auth'); I.fillField('Email', email); I.click('Login'); I.wait(2); I.fillField('Password', secret(password)); I.click('Sign in'); I.see('CodeceptJS Projects');
  33. 33. CODECEPTJS HELPERSCODECEPTJS HELPERS webdriverio Protractor Puppeteer Appium REST
  34. 34. TAKEAWAYS!TAKEAWAYS!
  35. 35. YOUR TESTING STORYYOUR TESTING STORY It's 2019, tests are not 👾 Test even if your code is 💩 Tests are: unit, functional, acceptance. Don't couple specification to implementation. Switch to JS for mobile & browser tests
  36. 36. YOUR OPENSOURCE STORYYOUR OPENSOURCE STORY Do the work you 💓 no matter you are paid or not Ask community leaders for promotion 👫 Write posts & articles 📖 Build community and team 🤗 Go to conferences! 🛫
  37. 37. THANK YOU!THANK YOU! Try Codeception3 / CodeceptJS today! codeception.com codecept.io

×