-
Notifications
You must be signed in to change notification settings - Fork 559
Unit tests in the tutorial #348
Description
Hello.
I've noticed last night that there is a section, or, rather sections, about unit testing in the ZF2 tutorial. This is indeed awesome, but! Seems to me that the unit tests are trying to be TDD-ish, but will instead just confuse newcomers trying to learn ZF2. Several reasons.
- The
Unit Testing
section is the first http://zf2.readthedocs.org/en/latest/user-guide/unit-testing.html. The problem with this being first is that it speaks about modules, ViewModels, and other things that the developer knows nothing about (yet). - It uses PHPUnit 3.5.15 as shown in the example outputs, but this should be the PHPUnit version we use to actually test ZF2 itself (which is 3.6.x I think).
- The next problem can be seen on the
Routing and controllers
section http://zf2.readthedocs.org/en/latest/user-guide/routing-and-controllers.html. The code itself are just 4 empty actions (index, add, edit, delete), but the tests are testing these 4 actions that they return a ViewModel, about which the developer still doesn't know anything about. And these tests PASS where it's obvious that they should fail.
This 3rd problem is the biggest one as this will confuse new developers the most: "How come my tests fail when they pass in the tutorial? What am I doing wrong?! ARGH!!"
I really do welcome these unit test examples in the tutorial, but I feel they should be either full-blown TDD tests, covering everything (including unit tests with mocks for TableGateways and Forms), first shown how they fail and then we fix and then they pass, or the entire Unit Testing section should be moved last (that is, before the Conclusion
section), and everything about unit testing should be here, and here only.
I, personally, vote for the latter - a Unit testing section at the end. Why? Because the developer came to learn about ZF2, and intermixed tests all over the place would just create confusion and would make things more difficult for newcomers.
Thoughts?