Archive
JUnit: Automatically Managing Mocks
In this article, we will extend JUnit to automatically create and manage mocks for us; dramatically reducing the amount of boilerplate code required to write a test. If you are accustomed to dependency injection, like Spring, you will thoroughly enjoy this.
Update: JUnit Articles
My first series of articles on JUnit have all been updated with complete source code, which is now housed in my Google Code repository.
Spring MVC: Integration Testing Controllers
One of the greatest benefits of Spring MVC is that it removes your dependency on a servlet container. In theory, you should be able to test your controllers, and your entire web stack, from a testing harness like JUnit. In reality, you become just as dependent on the wonderful services offered by DispatcherServlet and a complete WebApplicationContext (request parameter binding, validation, model attributes, request mappings, and aspects such as Spring Security). In this article, I will show you how to create a mock servlet context and WebApplicationContext from within JUnit.
JUnit: Generating Tests at Runtime (Part 4: Test Data)
JUnit has become the defacto standard for unit testing in Java. This series will explore how we can extend JUnit to better facilitate the development of reusable tests; reducing the effort required to achieve complete code coverage while minimizing test code maintenance and ensuring quality testing. In this fourth part we extend our factory runner with support for testing runtime generated data.
JUnit: Generating Tests at Runtime (Part 3: Testing Properties)
JUnit has become the defacto standard for unit testing in Java. This series will explore how we can extend JUnit to better facilitate the development of reusable tests; reducing the effort required to achieve complete code coverage while minimizing test code maintenance and ensuring quality testing. In this third part we will start taking advantage of our new functionality by writing tests for properties and constructors.
JUnit: Generating Tests at Runtime (Part 2: Custom Runners)
JUnit has become the defacto standard for unit testing in Java. This series will explore how we can extend JUnit to better facilitate the development of reusable tests; reducing the effort required to achieve complete code coverage while minimizing test code maintenance and ensuring quality testing. In this second part we I will discuss the chief means of extending JUnit: custom runners.
JUnit: Generating Tests at Runtime (Part 1: Overview)
JUnit has become the defacto standard for unit testing in Java. This series will explore how we can extend JUnit to better facilitate the development of reusable tests; reducing the effort required to achieve complete code coverage while minimizing test code maintenance and ensuring quality testing. In this first part we I will discuss the motivations for writing reusable tests and why JUnit, out of the box, is not sufficient.