-
-
Notifications
You must be signed in to change notification settings - Fork 5
Testing WebEngine applications
WebEngine's separation of concerns helps testing because different kinds of behaviour can be tested at the right level.
An application class can be unit tested without rendering a whole page. A page flow can be tested through the browser without pretending the framework internals are your responsibility to retest.
In a perfect world, test-driven development would shape the work from the start. In real projects, that is not always how things begin. Even so, the broad split still helps:
- application classes in isolation are a good fit for PHPUnit
- page-level behaviour is a good fit for Behat
The earlier a useful test exists, the safer later refactoring becomes.
Keep unit tests focused on application functionality. Try to test business rules where they actually live, rather than only through the page layer.
Use behavioural tests for page-level integration so the browser-facing flow is covered too. Avoid over-testing framework or language internals that are not part of your own application's behaviour.
TDD is a discipline rather than a switch you turn on once. Done well, it changes the shape of development because no application behaviour appears without a test proving it.
That creates confidence in user-critical flows, data handling, business rules, and the rendering of important pages. If you want to see that style applied to the to-do list example, continue with the todo list TDD tutorial.
When you're ready to deploy to production, have a production checklist to hand.
- File-based routing
- Page views
- Page logic
- Dynamic URIs
- Headers and footers
- Custom HTML components
- Page partials
- Binding data to the DOM
- DOM manipulation
- Hello You tutorial
- Todo list tutorial
- Address book tutorial WIP
- Blueprints
- Application architecture
- Coding styleguide WIP
- PHP environment setup WIP
- Web servers WIP
- Background cron tasks
- Database setup WIP
- Client-side compilation WIP
- Testing WebEngine applications WIP
- Production checklist WIP
- Security WIP