Unit testing 5: test-driven development

Tags:

In this post I’ll introduce the methodology known as test-driven development, and how to use it in your projects. The difference between “normal” and test-driven development (TDD) is that when doing TDD, you write unit tests for your new code before writing the code itself. This way you ensure good test coverage for your code, and your code will also …

Unit testing 3: Writing tests for existing code

Tags:

Now that you know what unit testing is and how to write and run tests, it’s time to look at writing tests in more depth. Today we’ll take an example class and write tests for it. We’ll also introduce some common testing methodologies.

Unit testing: Introduction

Tags:

Due to popular demand, I’ll be writing a bunch of posts on unit testing. In this post I’ll introduce unit testing: What it is, when it’s a good idea and when it might not be. I’ll also discuss a bit about what makes for a good unit test. Next week I’ll post a followup to this, which will be more …

Thoughts on unit testing and application design

Tags:

Here are some thoughts and observations regarding application design and unit testing in the quiz-project I recently wrote about. When I was writing the Amazing Programming Language Guessing Script, I didn’t first write any unit tests. Partially because I just wanted to test something quickly, partially because I didn’t think there was any point in doing it. When I later …

Database helper for PHPUnit

Tags:

When testing code which uses the database, you would usually want to make sure the database stays pristine for each test – All tables should be empty, as any extra data could interfere with the tests. You could probably write an extended Testcase class which automatically does this before each test in setUp and afterwards in tearDown, but it may …