Aug 25 2008

jUnit 4.x Test Suites…

Category: Java,TestingPhil @ 8:11 pm

Have you ever wanted to run all of your jUnit tests from within Eclipse? It is pretty easy if they are in the same package, but if you have a hierarchy of packages, you are out of luck! I learned quite a few jUnit tricks tonight, even found the exact code I was looking for. You can read about some annotation-based test suites at this site. This guy gave me the exact code I was looking for, maybe someday they will add this feature directly to jUnit!

I’m still digging Unitils as well… I found a cool annotation to rollback the transaction for a specific test case. This is kind of nice when you don’t want your jUnits messing up your database! Check this out…

@Test
@Transactional(TransactionMode.ROLLBACK)
public void validateLoad() {…}

https://www.beilers.com/wp-content/plugins/sociofluid/images/digg_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/reddit_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/dzone_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/stumbleupon_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/delicious_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blinklist_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/blogmarks_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/google_48.png https://www.beilers.com/wp-content/plugins/sociofluid/images/facebook_48.png

One Response to “jUnit 4.x Test Suites…”

  1. Kevin Maes says:

    Try using spring test framework. There a transactionconfiguration defaultRollBack=true
    So after each test a rollback is done. Now you don’t need to write tearDown/@After method to clear your DB

Leave a Reply