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 having the test tasks that we used heavily throughout the book; however, this time, they are limited only to specifications (unit tests). In addition, all integration tests can be run by clicking the testInteg task from the Gradle projects IDEA window or running the following command from command prompt:

gradle testInteg
  

Let us write a simple integration test.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.36.221