Contract Tests in JUnit 4

Published May 28th, 2010 Under Open Source Tools, Software Testing | Leave a Comment

As part of his talk on integration tests J.B. Rainsberger talked about how contract tests can be used to test the interaction between classes when using a mockist approach to developer testing. He wondered aloud if it would be possible to write these kinds of tests using abstract classes and JUnit 4. The answer is yes, with some caveats, as Ben Rady demonstrates it.


Video produced by Ben Rady

Listening to Test Smells

Published February 18th, 2010 Under Coding, Open Source Tools, Software Testing | Leave a Comment

This talk is about how to use the stresses of writing unit tests to improve your code. If I’m having trouble writing tests, it’s often because the design of my target code can be improved. The trick is to listen to the tests and let them drive my development — that’s a hint as to why it’s called Test-Driven Development. As a developer, you can sensitise yourself to find the rough edges in your tests and use them for rapid feedback about how to improved the design of your code. In this talk, I will work through examples of “smelly” tests, showing how they highlight design flaws and suggest improvements.

Watch this video on JavaZone (click on “Presentation”)

Easy and Maintainable Enterprise Testing with Unitils

Published February 10th, 2010 Under Open Source Tools, Software Testing | Leave a Comment

Unit testing has become a mainstream task. Most developers do it. Most project leaders and architects expect their team to write tests. However, practice has taught us that a lot of teams write few tests, or spend too much time writing and maintaining them. Different development teams make common mistakes, run into similar issues and find their own solutions for them. This costs a lot of valuable time. Unitils started in 2005 and has emerged from concrete experience and lessons learned, with the ultimate goal of making unit testing easy, effective and maintainable. Unitils offers a lot of support in testing the database layer: automatic maintenance of test databases, automatic post-processing of the database to make it more test-friendly, loading test data using DbUnit and verifying the contents of the database after execution of a test. Unitils provides specific support for testing with JPA or hibernate, and offers integration with spring. It makes abstraction of the testing framework that is used for executing the tests, making it useable with JUnit3, JUnit4 or TestNG. But Unitils is not limited to persistence layer testing only: The reflection assert utility is a very useful alternative to the classic assertEquals method with a range of leniency options. Unitils also provides superior support for dynamic mock objects, offering a simple syntax for specifying method behavior and verifying expectations. This talk will present the different features of Unitils using simple, concrete examples.

Watch this video on JavaZone (click on “Presentation”)

Object Oriented Design for Testability

Published January 13th, 2010 Under Coding, Software Testing | Leave a Comment

We design our code for performance, maintenance, simplicity, extensibility and other goals, but most of us do not think about testability as a design goal, yet verifying the correctness of our code is of great importance. What does it mean to have testable code, and what kind of trade offs does one have to think about when designing for testability. Turns out that testable code is well designed code, and it has many of the characteristics we search for such as low cohesion, separation of concerns, proper encapsulation and many others.

Improving on Unit Tests with Sonar

Published September 29th, 2009 Under Open Source Tools, Software Testing | Leave a Comment

Sonar enables to collect, analyze and report metrics on source code. Sonar not only offers consolidated reporting on and across projects throughout time, but it becomes the central place to manage code quality. This screencast shows how to use Sonar to manage unit tests by checking their results. When you are done, you can verify that components are properly covered.


keep looking »