GithubHelp home page GithubHelp logo

delivery-tests's Introduction

delivery-tests

Issue: testing the delivery layer is painful if done incorrectly.

Why?

  1. Using Laravel's phpunit based browser API to run a full stack test is enticing, but it only works within Laravel, and despite advertising testing through the template, it doesn't handle dynamic template testing.
  2. Writing full stack tests for each usecase scenario causes a build-up of slow running tests that usually require complex setups on DB and third party systems.
  3. Controller and view logic can grow to be relatively complex (i18n, geodetection issues, cookie and session handling). Testing has to be done.
  4. Controllers and views must be tested separately. Laravel makes this quite hard.
  5. Current delivery is not PSR-7 based, despite Laravel supporting it.
  6. Testing controller logic involves inspecting Requests and Responses, which Laravel hides within its magic.
  7. Testing superglobals? Funny REST stuff? Have fun!

Solution:

  1. Use Behat + Mink to run full stack tests. One full stack test per route, to function as a smoke test (only test for lack of errors and a rendered output).
  2. Move the controllers and views into our own namespace isolated from Laravel.
  3. Views are simple data massagers and are easy to test.
  4. Controllers perform HTTP logic. Therefore we must test through a PSR7 Request and Response. A mocked Loader and Renderer tool allows us to play out usecase scenarios and check that the view receives the results it needs.

delivery-tests's People

Contributors

moult avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.