phpunit

PHPUnit: Resources

 

PHP Sticking Points
* Strong Typing
    * False positives
    * Interpreting Code Intent
    * Debugging tests difficult, primary with larger teams
        * swapping int/string function arguments doesn't produce any IDE errors, so must detect/debug runtime.... could go undetected
    * Framework changes can create a multitude of undetected problems
* Return types limited
    * can't return Array of Objects, so IDE intellisense breaks
        * broken intellisense can't detect logic errors
        * trial and error required for using object functions since code hints not available.
*  Enums & other constructs not available

Tags

PHPUnit-Webdriver: 09 - PhantomJS ( GhostDriver )

  • https://github.com/detro/ghostdriver
  • PhantomJS has ghostdriver embedded so it is an all-in-one package
  • PhantomJS has crashes periodically, so have some concerns about using it.
  • As of 2018.11.28:
    • [FOR PHP] I currently prefer to use chromedriver with the --headless CLI spec for CI/CD use
      • if only to ensure consistent runtime & capability support
    • There are good reasons to implement other drivers - but I'd lean towards implementing other webdrivers AFTER a chromedriver solution is build & stable.
      • Then FireFox & IE headful
      • Then these two in headless
    • FireFox PHP driver currently has issues with the php-webdriver(Facebook WebDriver), so have not implemented FF in my latest PHPUnit-php-webdriver framework.

 


 

PHPUnit-Webdriver: 10 - PageObjectModel Framework

  • When testing web applications ( or any complex product ) modeling the application is critical for reducing maintenance overhead.
  • Tests should be abstracted away from interacting with the DOM & its elements such that they only reflect interactions
  • By modeling the application, creating tests is intuitive & element selectors are assigned one time in one place
    • Using enumerations and/or constants allow for indirect references to elements so if their selectors change, the only update needed is one constant assignment
  • When the framework is updated to reflect architectural changes in the product, updates will be contained and encapsulated
    • failing tests will show technical debt & expose possible impact to the product that may have not been anticipated.

 

Page Object Model

PHPUnit-Webdriver: 07 - ChromeDriver headless


 

 

Headless Chrome

To run Chrome browser in a headless environment, we need send an aurgument "--headless" to ChromeOptions. This option will tell Google Chrome to execute in headless mode.

Subscribe to phpunit