Posts Tagged ‘unit test’

Speeding up your DBUnit tests with JavaDB

June 8th, 2008 4 comments

Introduction to DBUnit

DBUnit logoWith the developed use of JUnit, many additions were made to it. These additions take advantage of the pluggable nature of JUnit. One of these contribution is DBUnit. DBUnit enables your unit tests to:

  • preload the database with datas pertaining to your current test only,
  • run your unit test (as usual),
  • remove the data you preloaded in order to put the database in the same it was before your additions.

In effect, you can now test your DAO classes. Let’s take a (very) simple example: Read more…

Send to Kindle
Categories: Java Tags: , , ,

The unit test war : JUnit vs TestNG

June 1st, 2008 5 comments

What is unit testing anyway?

If you’re in contact with Java development, as a developer, an architect or a project manager, you can’t have heard of unit testing, as every quality method enforces its use. From Wikipedia:

“Unit testing is a test (often automated) that validates that individual units of source code are working properly. A unit is the smallest testable part of an application. In procedural programming a unit may be an individual program, function, procedure, etc., while in object-oriented programming, the smallest unit is a method, which may belong to a base/super class, abstract class or derived/child class. Ideally, each test case is independent from the others.”

Unit tests have much added value, apart from validating the working of your classes. If you have to change classes that you didn’t develop yourself, you should be glad to have them… because if they fail, it would instantly alert you of a failure: you won’t discover the nasty NullPointerException you just coded in production!

Before the coming of testing frameworks (more later), the usual testing was done: Read more…

Send to Kindle
Categories: Java Tags: , ,