Alan van Dam
(0 comments, 4 posts)
This user hasn't shared any profile information
Posts by Alan van Dam
Complicated tree structures are being used a lot within my current project. Tree nodes have elements behind them. An element is unique, but there can be multiple tree nodes for a single element. Tree nodes have different drag and drop behavior based on flags on both the tree nodes and the elements. Also tree nodes can inherit children from other tree nodes etc. This blog will be about how to unit test these trees or more exactly how to setup a unit test so that it is fun to create and easy to maintain. (more…)
Last Monday I was attending a presentation of Brian Goetz about the Java Memory Model. One of his points was about lazy initialization which concluded with "don’t use the Double Checked Locking idiom". Last Thursdays keynote at Devoxx Joshua Bloch tells the audience that if you really, really need performance you should use the the double checked locking idiom.
A lot of interesting stuff is going on. More and more (dynamic typed) languages are appearing and getting more attention. Are they better than the Java language? (more…)
Writing unit-tests should be part of your development process whether you write them before or after the actual coding I leave that up to you. On of the pitfalls of writing unit tests is that the units become to big.
The unit your are testing, a method in most cases probably uses some other beans or services to do its job. In your unit test you don’t want to test those other beans but just your method. Because you use decoupling you can easily override the interfaces of the services in your test case and inject those services in your instance you are testing. This is an example of a mock object.
This is maybe good for one or two mock objects but it gets tricky. Who test the mock objects? You will soon get a lot of logic in the mock objects. To reuse them they need to be extracted from the unit test. You don’t have checks if the mock objects are really called. There are several frameworks that will do this mocking for you. You supply them the interface and they will give you an implementation which can be injected into the bean thats being tested. (more…)