A lot of people will tell you that unittesting is easy, but in practice it’s one of the hardest disciplines to get right. When you’ve never written unittests before you’ll probably have a million questions really fast; your code has got a lot of dependencies, runs queries on your database and sends out e-mails, and there seems to be no way to write reliable tests for this code that you can actually use time after time. No worries! Harrie is here to help 🙂
This tutorial is a hands-on code-along tutorial to writing unittests using PHPUnit. We’ll be writing some actual unittests for (sometimes problematic) pieces of code that you could come across while testing real-life applications. I’ll explain how you could apply TDD and how to use it into your advantage, and I’ll come with some suggestions on how you could convince your boss that unittesting is important and actually worth the effort on the long run.
Questions and Answers
Who’s the target audience for this tutorial?
The tutorial is meant for people who have little or no experience with writing unit tests. The tutorial is specifically designed for people who have no experience with unit testing. However, if you’ve already written some unit tests before and you’re not sure if you’re doing it the right way, or you simply want to see what else is possible, this will be a really interesting session as well.
How experienced do I need to be?
- At least some experience with programming PHP
- It helps if you know how to use the command line
Which version of software / php etc will you be covering?
- PHP 5.3 (or higher)
- phpunit 3.7 (or higher)
Do I need to bring a laptop?
Please do, although it’s not required. It is quite challenging to start off writing unit tests if you’ve never written one before, and I’m hoping that some hands-on experience will give you the knowledge and confidence to continue to write unit tests for your own project when you’re back at your job. However, it is a code-along session so if you just want to sit back and enjoy the show that’s fine as well.
Do I need to install or set-up any specific software prior to the day, in order to get the most out of the day?
We will cover installing the required tools during the tutorial, however if you could install php 5.3 (or higher) and the current stable version of phpunit (probably 3.7, or maybe 3.8 by then) that would mean we could start off more quickly and therefore cover more content.
There will be flash drives available with virtualbox images where everything is already pre-installed. If you want to use those, it might be a good idea to install virtualbox from their website:https://www.virtualbox.org/wiki/Downloads
What else will I get?
Refreshments and lunch, a personalised attendance certificate and a conference T-shirt!
A hands-on introduction to writing unittests using PHPUnit