1

I have an application where I want to upgrade a library from an old version to a new version (Kafka client 0.8 to 0.10). Unfortunately the the new version introduces a breaking change which forced me to fix a broken unit test by using the new method signatures.

This works fine but due to the major upgrade I want to support both versions of the library using separate build profiles - one for 0.8 and one for 0.10. I know how to do that for the dependencies themselves but what's the proper way to include a different test file depending on the build profile? Is this even the right way to approach it?

Ideally I'd be able to write the unit test to work in both versions but I haven't been able to figure out how to just yet, or whether it's even possible.

Dan Goldin
  • 957
  • 13
  • 32

2 Answers2

2

You could set different test source directories in your profiles:

<properties>
  <project.build.testSourceDirectory>src/test/v010</project.build.testSourceDirectory>
</properties>
Stefan Birkner
  • 24,059
  • 12
  • 57
  • 72
1

I know how to do that for the dependencies themselves but what's the proper way to include a different test file depending on the build profile?

You could use JUnit test categories. You'll probably have to upgrade the version of maven-surefire-plugin as well.

Community
  • 1
  • 1
Mykhailo
  • 1,134
  • 2
  • 17
  • 25
  • Ah interesting - I've never heard of maven-surefire-plugin or test categories before. It seems it will still show up as having an error in the IDE though - that's something I'm trying to avoid. – Dan Goldin Nov 01 '16 at 01:46