Skip to content

Commit e2b77ab

Browse files
authored
Merge pull request #19 from wkrzywiec/spock-tests
Spock depenencies tests
2 parents 9b0c37f + 967a349 commit e2b77ab

File tree

2 files changed

+68
-9
lines changed

2 files changed

+68
-9
lines changed

pom.xml

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,27 +91,36 @@
9191
<version>1.2.32</version>
9292
</dependency>
9393

94+
<!-- TEST dependencies -->
9495
<dependency>
9596
<groupId>org.springframework.boot</groupId>
9697
<artifactId>spring-boot-starter-test</artifactId>
9798
<scope>test</scope>
98-
<exclusions>
99-
<exclusion>
100-
<groupId>org.junit.vintage</groupId>
101-
<artifactId>junit-vintage-engine</artifactId>
102-
</exclusion>
103-
</exclusions>
10499
</dependency>
105100
<dependency>
106-
<groupId>com.tngtech.archunit</groupId>
107-
<artifactId>archunit-junit5</artifactId>
108-
<version>0.13.1</version>
101+
<groupId>org.spockframework</groupId>
102+
<artifactId>spock-core</artifactId>
103+
<version>1.3-groovy-2.5</version>
104+
<scope>test</scope>
105+
</dependency>
106+
<dependency>
107+
<groupId>org.spockframework</groupId>
108+
<artifactId>spock-spring</artifactId>
109+
<version>1.3-groovy-2.5</version>
109110
<scope>test</scope>
110111
</dependency>
111112
<dependency>
112113
<groupId>io.rest-assured</groupId>
113114
<artifactId>rest-assured</artifactId>
115+
<scope>test</scope>
116+
</dependency>
117+
<dependency>
118+
<groupId>com.tngtech.archunit</groupId>
119+
<artifactId>archunit-junit5</artifactId>
120+
<version>0.13.1</version>
121+
<scope>test</scope>
114122
</dependency>
123+
115124
</dependencies>
116125

117126
<build>
@@ -144,8 +153,25 @@
144153
<artifactId>maven-surefire-plugin</artifactId>
145154
<configuration>
146155
<reportsDirectory>${surefire.and.failsafe.report.dir}</reportsDirectory>
156+
<includes>
157+
<include>**/*Spec.java</include>
158+
<include>**/*Test.java</include>
159+
</includes>
147160
</configuration>
148161
</plugin>
162+
<plugin>
163+
<groupId>org.codehaus.gmavenplus</groupId>
164+
<artifactId>gmavenplus-plugin</artifactId>
165+
<version>1.10.0</version>
166+
<executions>
167+
<execution>
168+
<goals>
169+
<goal>addTestSources</goal>
170+
<goal>compileTests</goal>
171+
</goals>
172+
</execution>
173+
</executions>
174+
</plugin>
149175
<plugin>
150176
<groupId>org.jacoco</groupId>
151177
<artifactId>jacoco-maven-plugin</artifactId>
@@ -263,6 +289,7 @@
263289
<sonar.sources>.</sonar.sources>
264290
<sonar.inclusions>src/main/java/**,src/main/resources/**</sonar.inclusions>
265291
<sonar.exclusions>${code.coverage.exclusions}</sonar.exclusions>
292+
<sonat.tests>src/test/groovy,src/test/java</sonat.tests>
266293
<sonar.projectKey>wkrzywiec_library-hexagonal</sonar.projectKey>
267294
<sonar.organization>wkrzywiec</sonar.organization>
268295
<sonar.coverage.jacoco.xmlReportPaths>target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package io.wkrzywiec.hexagonal.library.domain.borrowing
2+
3+
import io.wkrzywiec.hexagonal.library.domain.borrowing.core.BorrowingFacade
4+
import io.wkrzywiec.hexagonal.library.domain.borrowing.core.model.AvailableBook
5+
import io.wkrzywiec.hexagonal.library.domain.borrowing.core.model.MakeBookAvailableCommand
6+
import io.wkrzywiec.hexagonal.library.domain.borrowing.core.ports.outgoing.BorrowingEventPublisher
7+
import spock.lang.Specification
8+
9+
class BorrowingFacadeSpec extends Specification {
10+
11+
private BorrowingFacade facade;
12+
private InMemoryBorrowingDatabase database;
13+
private BorrowingEventPublisher eventPublisher;
14+
15+
def setup(){
16+
database = new InMemoryBorrowingDatabase();
17+
eventPublisher = new BorrowingEventPublisherFake();
18+
facade = new BorrowingFacade(database, eventPublisher);
19+
}
20+
21+
def "Make a book available"(){
22+
23+
given: "prepare a command"
24+
def command = new MakeBookAvailableCommand(100L)
25+
26+
when: "receive MakeBookAvailableCommand"
27+
facade.handle(command)
28+
29+
then: "check database to have this book as available"
30+
database.availableBooks[100L].idAsLong == new AvailableBook(100L).idAsLong
31+
}
32+
}

0 commit comments

Comments
 (0)