Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Unit testing

Options
  • 14-10-2013 5:06pm
    #1
    Closed Accounts Posts: 4,436 ✭✭✭


    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


Comments

  • Closed Accounts Posts: 8,016 ✭✭✭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.


  • Closed Accounts Posts: 4,436 ✭✭✭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


  • Registered Users Posts: 1,275 ✭✭✭bpmurray


    Martin Fowler's article on dependency injection is a great place to start: http://martinfowler.com/articles/injection.html


  • Registered Users Posts: 27,114 ✭✭✭✭GreeBo


    Look into libraries like mockito, jmockit, powermock to make testing legacy (and all code) much easier.
    They are available for multiple languages.


  • Moderators, Technology & Internet Moderators Posts: 1,334 Mod ✭✭✭✭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.


  • Advertisement
  • Moderators, Society & Culture Moderators Posts: 15,728 Mod ✭✭✭✭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.


Advertisement