I’ve recently been looking into some JavaScript unit testing frameworks. There are many alternatives, and while many of them seem good, very few of them actually matched my requirements: Must be able to run tests from the commend-line Tests should be relatively easy to write
Unit testing 5: test-driven development
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 4: Mock objects and testing code which uses the database
After learning to write tests and some good testing practices, it’s now time to look at mock objects. When testing a class which needs an instance of another class to work, you do not want to depend on the other class too much. This is where mock objects come in – a mock object is a “clone” of an object, …
Unit testing 3: Writing tests for existing code
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 part 2: Writing and running tests
Continuing from the unit test introduction, we will now continue and take a look at how to write tests and ways to run the tests.
Unit testing: Introduction
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
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
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 …
Ideas for testing Zend Framework apps
Here are some ideas I was thinking of for making testing Zend Framework (and Doctrine) based apps nice and easy.