WordPress plugin testing unit test or acceptance test or both WordPress plugin testing unit test or acceptance test or both selenium selenium

WordPress plugin testing unit test or acceptance test or both


(Ian pinged me on Twitter and asked me to provide some feedback)

First, I will say that I have not used the combo of PHPUnit and Selenium for doing acceptance testing. I use Behat + Mink to do that, but that's not the issue here I think.

To test a login form, you could do unit tests AND acceptance tests. It's just a question of whether or not you feel it's valuable to do both. I think from the perspective of building a WordPress plugin, you will get a much better return on the time creating the tests to go with acceptance tests.

Some other answers:

  1. Unit testing stuff that spits out HTML is totally acceptable. After all, the goal is to make sure that individual module of code works correctl
  2. Testing that error messages on failed logins occur should be in it a separate test. These days, I like to practice "one assertion per test" at the unit level

Hope this helps!