When using JUnit in Spring there are several features added that many developers are not aware of.
First, if you are including the Spring Context in your tests, it becomes an Integration Test, no longer a Unit Test.
ClassMock is a framework that helps the creation of unit tests for components that use reflection or annotations. In this kind of classes, the behavior is dependent of the class structure. This way, each test case usually works with a different class created specifically for the test. With ClassMock is possible to define and generate classes in runtime, allowing a better test readability and logic sharing between tests.
This library allows you to use JavaBeans-style property matching for arguments when using EasyMock. Property matching is based on commons-beanutils as documented in Standard JavaBeans.
TestabilityExplorer.org records the testability scores for many open source and commercial Java libraries.
The compiled bytecode for the library is analyzed and metrics are calculated for the testability of individual classes. Those classes fall into one of three categories - 'excellent', 'good' and 'needs work'. Generally speaking, injectability, mockabiliy and composition are good, and static state is bad. Figures are recursively calculated, but only inside the jar in question.
The metrics are a calculation of the skill of the development team in making their classes testable. You cannot use these metrics to say that Tomcat is better than Jetty or vice versa, as the features of each are not taken into account. These metrics will also not tell you whether a particular library will be easy to use or not. It just tells you how dedicated the development team was to making testable software. As we track the changing figures overtime, we can see whether the team in question was dedicated to improvement or not.
FEST-Assert is a Java library that provides a fluent interface for writing assertions. Its main goal is to improve test code readability and make maintenance of tests easier.
FEST-Assert requires Java SE 5.0 or later and can be used with either JUnit or TestNG.
Unitils is an open source library aimed at making unit testing easy and maintainable. Unitils builds further on existing libraries like DBUnit and EasyMock and integrates with JUnit and TestNG.
Unitils provides general asserion utilities, support for database testing, support for testing with mock objects and offers integration with Spring and Hibernate. It has been designed to offer these services to unit tests in a very configurable and loosely coupled way. As a result, services can be added and extended very easily.
Currently Unitils offers following features:
* General testing utilities
o Equality assertion through reflection, with different options like ignoring Java default/null values and ignoring order of collections
* Database testing utilities
o Automatic maintenance and constraints disabling of unit test databases
+ Support for Oracle, Hsqldb, MySql, DB2, Postgresql and Derby
o Simplify unit test database connection setup
o Simplify insertion of test data with DBUnit
o Simplify Hibernate session management for unit testing
o Automatically test the mapping of Hibernate mapped objects with the database
o Manage transactions during unit testing
* Mock object utilities
o Simplify EasyMock mock object creation
o Simplify mock object injection
o EasyMock argument matching using reflection equality
* Spring integration
o ApplicationContext configuration and easy injection of spring managed beans into a unit test
o Support for using a Spring-configured Hibernate SessionFactory in unit tests.
The project started begin 2006 from an Ordina J-Technologies discussion group on unit testing. The result was a list of guidelines and Unitils emerged in an attempt to write code to support these guidelines.
Documentation
Interfaces and Abstract Classes are language constructs that appear over and over in many design patterns and even just in good design techniques. It is common for a single interface or abstract class to have many different descendants or implementations. A good example of this scenario is the Strategy Pattern which relies heavily on many implementations of the same interface.
It is desirable to have one test suite that tests functional compliance with the interface that could be applied to each of the implementing classes.
Popper extends JUnit to allow you to specify theories, general statements about your code's behavior that may be true over infinite sets of input values. For a detailed description of why you might want to do this, see our paper. If you just want to try it out and get started, here's the place.
For those of you who've got into it you'll know that test driven development is great. It gives you the confidence to change code safe in the knowledge that if something breaks you'll know about it. Except for those bits you don't know how to test. Until now XML has been one of them. Oh sure you can use "<stuff></stuff>".equals("<stuff></stuff>"); but is that really gonna work when some joker decides to output a <stuff/>? -- damned right it's not ;-)
Nice article on IBM deveWorks: Ready to step up to the plate and hit a home run with your developer testing activities? In this installment of Automation for the people, development automation expert Paul Duvall covers some of the various types of automated developer tests you can run with every source code change. Paul provides examples of Selenium, DbUnit, and JUnitPerf tests that can help you discover application problems early -- that is, if they're run often.
JUnitPerf is a collection of JUnit test decorators used to measure the performance and scalability of functionality contained within existing JUnit tests.
Great ! - You're into Extreme Programming. You've written the tests ( JUnit of course). You've done the most simple thing that could possibly work. You've even shared your keyboard with a colleague. But have you done enough?
From Google's Summer of Code 06: Testar is a tool designed to reduce the time spent running Java unit tests. It runs on top of JUnit and automatically selects individual tests to run based on what tests previously succeeded and what changes you have made
EasyMock provides Mock Objects for interfaces in JUnit tests by generating them on the fly using Java's proxy mechanism. Due to EasyMock's unique style of recording expectations, most refactorings will not affect the Mock Objects. So EasyMock is a perfect