Discussions
Categories
Groups
Advertisement
Child Item
Home
Topics
Technology & Internet
Software & Web Development
Development
Unit testing
c_man
Hey,
So I want to improve my unit test skills and am looking for any recommendations on good resources (books, sites etc.).
I've heard good things about 'Working Effectively with Legacy Code', anyone read it?
Thanks
Find more posts tagged with
Quick Links
All Categories
Recent Posts
Activity
Unanswered
Groups
Best Of
Advertisement
Advertisement
Comments
CreepingDeath
You don't say what language you use.
Eg. in Java then "junit" is commonly used for pure java testing.
Maybe with some Spring framework injected classes too.
If you've a web app, then there's a range of Web testing software... eg. Canoo, Selenium, Silk etc.
c_man
C++ but I don't think it matters much. We have the setup done and running, I'm not looking for tech as such but rather resources on how to design code with unit test in mind, adapting existing code bases for same
bpmurray
Martin Fowler's article on dependency injection is a great place to start:
http://martinfowler.com/articles/injection.html
GreeBo
Look into libraries like mockito, jmockit, powermock to make testing legacy (and all code) much easier.
They are available for multiple languages.
croo
c_man
wrote:
»
I've heard good things about 'Working Effectively with Legacy Code', anyone read it?
I have it sitting by my bed for about 6 months but haven't done anything other than flick through it - but it was recommended by someone who has a lot of experience so I guess I will eventually read it. From the little bit I did see it was approaches like wrapping the legacy code and unit testing the new wrapper you wrote.
I'll try and have a more detailed flick through over the coming week!
PS. posts re martin fowlers DI remind me of his other excellent book on Refactoring. Though most of it is strategies that are mostly handled now by tools in the IDEs such as Eclipse. But the first few chapters are very interesting to see how and what he addresses in a simple example application.
smacl
I think testing is better approached top down rather than bottom up. Start with a testing strategy, testing goals and then figure out how to achieve those goals. Running a small software house, also all C++ FWIW, I got quite involved in software quality some years back in order to try an figure out the most effective way of delivering a stable product that was undergoing a lot of continuous change. Some discussion on the approach I took back then
here
. At a technical level, I use
design by contract
a fair bit, with a
modified assert system
driven by unit and GUI level automated regression testing. For decent test coverage, as opposed to code coverage, of a complex application, I find robust GUI level automation is a necessary part of the mix, particularly where you're dealing with lots of 3rd party libs of unknown quality.
Injecting faults into regression base line data
used in automated regression testing also works well to test the tests.
+1 on Fowler's book on refactoring. Well worth reading even if some of what is covered these days is handled by tools, as the reasons why are as important as the question how. For legacy C & C++ code, and working with other peoples code in general, Whole Tomato's Visual Assist rocks IMHO, and is a decent investment.