I’m building a WordPress plugin and I want to build using test driven development.
The first thing I want to test / build is a login form.
I’m unsure if I should be unit testing it, acceptance testing or both.
I’ll be using PHPUnit and Selenium.
The first thing I started looking at is displaying the login form. Is it good practice to unit test returning HTML?
Also this form may contain error messages on failed logins. Would this be a different unit test or is this best left to acceptance testing?
I’ll post some code example if I need to clear anything up.
Thanks
(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:
Hope this helps!