예제 2-5에서는 앞에서 구현한 두 메서드를 테스트한다. 코드에서 볼 수 있듯이 간단한 문서를 생성하고, 해당 문서가 findByType 메서드 호출로 얻은 Document 리스트에 있음을 단정한다. 이제 그레이들을 이용해 테스트 클래스를 실행하자. 예제 2-6은 이 유닛 테스트를 실행하는 데 사용할 build.gradle 파일을 보여준다.
예제 2-6 build.gradle
apply plugin: 'java'
group = 'com.apress.isf'
version = '1.0'
repositories {
mavenCentral()
}
dependencies {
compile("org.codehaus.groovy:groovy-all:2.3.+")
compile("org.springframework:spring-context:4.0.6.RELEASE")
testCompile("junit:junit:4.11")
}
test {
testLogging {
events 'started', 'passed'
}
}