Testing in WordPress

Max Kovalenkov

Marshmallow Experiment

Our Hero

Day 0: The Jeopardy

Day 5: "All is Lost" (kind of)

Methodologies...

  • TDD
  • BDD
  • FDD
  • DDD
  • MDD
  • ...
  • ADHD

Why test?

No more "Déjà Vu"s

Design

Document

...

Confidence

"We write tests to enforce decisions."

- Andrew Nacin

"You can't charge your client for mistakes in your old code that just broke."

- Chris Lema

Ok, convinced. But...

When not to test?

  • External dependencies
  • One-off stuff or trivial code
  • Test is way harder to write than code
  • 100% test coverage?

When to test?

  • All the other times!

Acceptance

Functional

Integration

Unit

Catapult

TDD

(test-driven development)

The Epiphany

Day 9: The Tools

Unit tests - not always enough

Codeception

Theme Check plugin

Wraith

Wraith at work

Wraith report

How to start?

CI

(continuous integration)

Travis CI

Day 27: Monday

Day 31: Friday

Day 90: team lead

Thank you!

twitter @m0ntrealist

Testing in WordPress

By Max Kay

Testing in WordPress

Testing has always been and continues to be something of a "skeleton in the closet" for most developers. It's rarely required as part of the development process, is often tedious to set up, and, to be effective, needs to become a regular practice both before and after going live. Yet bringing it into our work routines provides numerous benefits in the long run and, if done properly, can save lots of headaches and at times even help avoid a tainted reputation. We will start by looking at the automated testing landscape from the high level - what's what and where's best to use each testing methodology. We will then explore testing options available for different parts of the WordPress ecosystem (core, plugins, themes), and go through a couple of practical examples of using selected test frameworks. To finish off, we'll discuss the habit-forming aspect, which is not necessarily as much about development itself.

  • 4,751