10

I was used to naming my JUnit Integration tests with a *Test.java on the end eg DatabaseConnectionTest.java and placing them in their own integration test directory: eg test/integration/com...

On joining a new project I was directed

No, all the Tests go in the one directory, and we distinguish the Unit Tests from the Integration tests by pattern matching on the file name suffix.

So my file above would become DatabaseConnectionIT.java

Now I can see the logic in this. The test runner script can just pattern match for the files it is looking for, and all the tests are in the one location.

But I had never heard of the convention.

My question is: Is the 'IT.java' filename Suffix (instead of 'Test.java') for JUnit Integration Tests a convention?

hawkeye
  • 34,745
  • 30
  • 150
  • 304
  • In my opinion, it seems as much as a convention as INT for interface is. – Pieter De Bie May 06 '15 at 12:46
  • It's a convention where you're at, which is enough. It's not a universal convention, for example, I group types of tests by directory, so the file and class names don't have funky abbreviations. – Dave Newton May 06 '15 at 12:57
  • 1
    It's one of the [default patterns](http://maven.apache.org/surefire/maven-failsafe-plugin/integration-test-mojo.html#includes) recognized by the Maven Failsafe plugin, so it's hardly eyebrow-raising. ...what's your question, exactly? – kryger May 06 '15 at 13:11

1 Answers1

21

The IT.java suffix is a convention used by the Maven Failsafe Plugin. All classes in the test directory that have the suffix IT are executed by this plugin in the integragion-test phase. (Tests with suffix Test are exectued by the Maven Surefire Plugin in the test phase.)

Stefan Birkner
  • 24,059
  • 12
  • 57
  • 72
  • 1
    failsafe will also execute tests annotated with categories that are specified in the `groups` parameter https://maven.apache.org/surefire/maven-failsafe-plugin/examples/junit.html – dkatzel May 06 '15 at 16:00