Unit Testing Fundamentals
Below and attached are slides from a presentation I gave to colleagues at Kiwiplan. The presentation covers a range of topics regarding unit testing best practices, including test driven development (TDD), mocking frameworks, avoiding over-specification and test coverage. The slides also include diagrams to help explain the concept of isolating code through the use of seams.
I’ve attached the final outcome of the live TDD examples. Obviously TDD doesn’t come across very well as a final solution, however the code also provides basic examples of the Mockito and Rhino Mocks libraries. The code style is based on Spring Framework’s annotation driven MVC framework.
Java example code – JUnit, Mockito, EclEMMA (Eclipse Java coverage)
VB.Net example code – NUnit, Rhino Mocks
3 Comments to Unit Testing Fundamentals
You do realize that Typemock will allow you to achieve the same things without the need to “Expose a Seam”, or more specifically static are a seam like any other method (the same holds when using the Java PowerMock tool)
Thanks for the comment Lior. I had heard of Typemock, but not of PowerMock. I like the idea that code remains loosely coupled when a seam is exposed, but now that I know about PowerMock I’ll have a play with it and see how it goes.
Here are a couple more links on the subject (thanks Rob)
SOLID (object oriented design):
http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod
FIRST (unit testing best practices):
http://agileinaflash.blogspot.com/2009/02/first.html
Leave a comment
Search
Subscribe
Recent Posts
Tags
Archives
What I'm Doing...
- RT @jamescarr: I prefer story level specifications that setup their own inputs versus relying on crap that's already in the DB 6 hrs ago
- @alexcuesta Sounds like #qcon was great! Are you staying for https://secure.trifork.com/london-2010/freeevent/register.m?eventOID=2346 7 hrs ago
- Missed my tube stop playing Archipelago, sign of a compelling game. If only it had multiplayer #android 15 hrs ago
- More updates...
March 2, 2009