Category Archives: Testing

Spring Test Framework CoC suggestion

Let’s say you’re using JUnit 4 and the Spring Testing classes (the 2.5+ versions) for your unit tests. You can specify parameters as shown in the TransactionConfiguration annotation as shown in this example. But you can also get away with leaving them out in a nod to the uberhip Convention Over Configuration gods as shown […]

Also posted in Spring Framework | Tagged , , | 1 Response

Spring and Transactions

I’ve been taking a legacy codebase, putting testing in place and refactoring. For DB access I retrofitted the persistence classes to be injected via Spring with a DataSource instead of looking them up via JNDI. IN my Spring context I defined a PlatformTransactionManager.

Then I refer to it in the the test case class. […]

Also posted in DB, Spring Framework | Tagged , | Leave a comment

JUnit4, Selenium and Spring test context

In a previous post I wrote about using JUnit4 with Selenium. So how about injecting your JUnit run listener via Spring? My first attempt modified my runner to be a subclass of SpringJUnit4ClassRunner Then I created the usual XML spring config file but named it after my test class name. So for FooTests I created […]

Also posted in Selenium, Spring Framework | Tagged , , | 3 Responses

JUnit4 and Selenium

The Selenium website seems to be biased towards TestNG. That’s fine but I’m using JUnit4. One nice feature of the selenium testcase class is to produce a screendump for failures. But it’s a JUnit 3 class; it seems they have not noticed that JUnit4 exists. So how to get a screendump with a JUnit4 test […]

Also posted in Selenium | Tagged , | 3 Responses