1

I'm working on an application with an public api for which is thoroughly tested with a lot of JUnit 3 tests. There have been some changes and there are now two initial configuration setups to test. I would like to just run all test suites with each configuration, but based on initial conditions a small set of api methods now behaves differently. I would like to implement some annotations or use assumptions to toggle test methods, but I am actually stuck on Java 1.4 so annotations and JUnit 4 are out of reach ...

Any ideas how to progress from here? I would like to avoid splitting classes or moving methods around due to semantic reasons.

A note: those tests are not trivial, just configuring expected results on configuration does not work.

Of course I could do something like

public testAbc() {
  if (cond) 
      testAbc0();
  else 
      testAbc1();
}

but this strikes me as rather ugly.

Max Power
  • 178
  • 1
  • 10
  • If you want to use annotations perhaps you can use one of the tools that supports backporting them to 1.4. See http://stackoverflow.com/questions/1011706/backport-java-5-6-features-to-java-1-4 – Mark Jan 06 '14 at 16:20
  • Even if your deployment has to target 1.4, consider using a later release for your tests (e.g. [Different maven compiler versions for test and main](http://stackoverflow.com/questions/1213897/different-maven-compiler-versions-for-test-and-main)). – Joe Jan 10 '14 at 11:53
  • @Joe Sorry for later answer, this is actually how it works now. API is compiled with Java 1.4 but tests suites are now run in a Java 6 VM. Please add your comment as answer so I can accept it. – Max Power Jan 17 '14 at 12:02

1 Answers1

0

Even if your deployment has to target 1.4, consider using a later release for your tests (e.g. Different maven compiler versions for test and main).

This will allow you to deploy binaries that were compiled with a 1.4 JDK and still take advantage of any later features in test frameworks, as well as building experience with current Java to prepare for a production upgrade.

Community
  • 1
  • 1
Joe
  • 29,416
  • 12
  • 68
  • 88