Showing posts with label JUnit. Show all posts
Showing posts with label JUnit. Show all posts

Thursday, February 17, 2011

Integrate MyBatis 3.x with Spring 3.x

Since last I wrote about integrating Spring with iBatis, and about using the very useful auto-rollback in Spring Test Framework, things have changed. The iBatis project has shifted to Google and is now called MyBatis, and includes numerous API changes. But, this was done after Spring 3.0 was released - so full integration with Spring was left undone at that time. However, a Spring-MyBatis integration component is now available, and here I'll write up how to use it to very simply use MyBatis, preserving the auto-rollback feature.

Wednesday, February 2, 2011

Enable Assertions with JUnit Tests in IDEA

My test cases have recently been converted from TestNG to JUnit4, and to my surprise every single test I wrote from that point forward passed without a problem - if I ran the tests in my Intellij IDEA 9.0.4 IDE. Mysteriously, executing them via Maven did not have that same result (whether from command line or from IDEA). As it turns out - apparently JDK assertions are enabled by default when I use TestNG in IDEA, but not so much when using JUnit.

Fix this problem by setting the -ea VM argument for all existing tests, and setting that as a default for JUnit tests created from this point forward.

Arrrggghhhh.

Thursday, January 27, 2011

Periodic Task and Watchdog - Reusable and Testable Versions

In my previous post, I presented a simple utility for a periodically executing task and a watchdog to make sure it runs forever. Now I'll refactor that prototype code to make things generic and reusable.