Over a million developers have joined DZone.

A Couple of Eclipse Tidbits for Testing

· Java Zone

Learn more about how the Java language, tools and frameworks have been the foundation of countless enterprise systems, brought to you in partnership with Salesforce.

I finally mapped Rerun JUnit Test using the keymapping stuff in eclipse. I know there was already a way to get to it using those key combinations where it‘s like 3 and then a letter afterwards. Too much work. I chose command-Shift-J (since I have become seriously kneejerk about command-Shift-F), it‘s kind of same bit on the other hand. Makes a huge difference, however, when you switch between tests you have to remember that it is not going to run the test you are in.

Made a template for adding the Spring runner stuff to the top of tests.

@ContextConfiguration(locations = { "/${contextFile}.xml" })
@TransactionConfiguration(defaultRollback = true)

Was thrilled to see the third one can be added so I don‘t have to think about rollback. However, you do have to mark the tests themselves as @Transactional and I got bitten by that again. The rule there is pretty simple: if you have a simple test, that calls one method on the Repository, it will likely work w/out the annotation on the test. Soon as you try and say, create 2 things, then do a find to make sure it‘s seeing them, you will get transient errors, even though the cascades are there. Once I added the annotation, I got an error about CGLIB not being present. Added the dependency to the pom and the problem went away.

Here‘s a template for doing a suite. Of course, it won‘t add the classes for you, but the wizard in the plugin does not support 4.x syntax (per prior post):

@Suite.SuiteClasses( { ${classNames} })


Another stupid thing happened today where I was writing a test that submitted a couple events then did a query for all events since. I made the date doing the usual Date begin = new Date(), then created the 2 events, and have a since clause on the query and I passed it the begin. The thing was failing. Added Thread.sleep(10) and it passed.. ? So apparently, it was looking like the same date, even though, it was a TIMESTAMP (TemporalType), and I used the 3 argument setParameter call to stipulate so. Figured the 10ms delay was preferable to adding a bunch of ugly JDK-based date math. (Thrilled to find the other day that Hibernate now has support for persisting Joda types.)

From http://www.jroller.com/robwilliams


Discover how the Force.com Web Services Connector (WSC) is a code-generation tool and runtime library for use with Force.com Web services, brought to you in partnership with Salesforce.


The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}