O'Reilly logo

Test-Driven Java Development - Second Edition by Viktor Farcic, Alex Garcia

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Tests separation

If we follow some kind of convention, it is fairly easy to separate tests in Gradle. We can have our tests in different directories and distinct packages or, for example, with different file suffixes. In this case, we choose the latter. All our specification classes are named with the Spec suffix (that is, TicTacToeSpec). We can make a rule that all integration tests have the Integ suffix.

With that in mind, let us modify our build.gradle file.

First, we'll tell Gradle that only classes ending with Spec should be used by the test task:

test { 
    include '**/*Spec.class' 
} 

Next, we can create a new task, testInteg:

task testInteg(type: Test) { 
    include '**/*Integ.class' 
} 

With those two additions to build.gradle, we continue ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required