How to approach JUnit for unit testing

How to approach JUnit for unit testing

I like JUnit from what I hear. I do not know how to use it. Please kindly advise me how to use it.

    Requires Free Membership to View

    When you register, you'll receive targeted emails designed to keep you informed of the most relevant information on Agile development, application security, testing & QA, software requirements, and more.

    Hannah Smalltree, Editorial Director

    By submitting your registration information to SearchSoftwareQuality.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchSoftwareQuality.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

In 2005 Dana Spears and I held a workshop on unit testing in Indianapolis. I published some of the findings of that workshop here. At the end of that article, I recommended a number of resources for getting started. That list included Kent Beck's Test-Driven Development: By Example (Addison-Wesley, 2002, ISBN 0321146530) and TestDriven.com.

Software testing resources:
Building beautiful software tests around JUnit

Unit testing critical for improving software quality

Find software bugs, defects using code coverage

Given that you asked specifically about JUnit, I would also recommend the JUnit documentation on SourceForge. A great example which walks you through specific tests (follow along in JUnit as you read it) is JUnit Test Infected: Programmers Love Writing Tests. Once you've read a bit about it, the best way to learn is to start doing it. Just start. The more you do it, the easier it gets.

This was first published in November 2009