-
Notifications
You must be signed in to change notification settings - Fork 0
Spock Maven
정명주(myeongju.jung) edited this page May 9, 2018
·
3 revisions
-
mvn clean test
: only unit-test -
mvn clean verify
: unit-test + integration-test
<properties>
<spock.version>1.1-groovy-2.4</spock.version>
</properties>
<dependencies>
<!-- test:spock -->
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-spring</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-bom</artifactId>
<version>${spock.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencyManagement>
<build>
<plugins>
<!-- The gmavenplus plugin is used to compile Groovy code. To learn more about this plugin,
visit https://github.com/groovy/GMavenPlus/wiki -->
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<goals>
<goal>compileTests</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<useFile>false</useFile>
<excludes>
<exclude>**/*Spec.java</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>test</goal>
</goals>
<phase>integration-test</phase>
<configuration>
<excludes>
<exclude>none</exclude>
</excludes>
<includes>
<include>**/*Spec.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
- src
- main
- java
- resources
- test
- groovy : TestCase by Spock
- java
- resources
- main
class WikiServiceTest extends Specification {
WikiService service
// mock
WikiRepository wikiRepository
WikiSettingService wikiSettingService
// fixture
Project project
ProjectAdmin admin
void setup() {
wikiRepository = Mock()
wikiSettingService = Mock()
service = new WikiService(wikiRepository, wikiFactory, wikiSettingService)
project = random(Project)
admin = random(ProjectAdmin)
}
def "Create"() { // dooray-위키/9
given:
def willCreateWiki = randomWiki(null)
def createdWiki = random(Wiki)
when:
def result = service.create(project, admin)
then:
1 * wikiRepository.save(willCreateWiki) >> createdWiki
and:
result == createdWiki
}
}
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
class WikiServiceSpec extends Specification {
@Autowired
WikiService wikiService
def "Create"() {
given:
def project = random(Project)
def admin = random(ProjectAdmin)
when:
def result = wikiService.create(project, admin)
then:
result.wikiId != null
result.tenantId == project.tenantId
result.projectId == project.projectId
result.createOrganizationMemberId == admin.organizationMemberId
result.createdAt != null
}
}
pom.xml
<profiles>
<!-- sonar -->
<profile>
<id>sonar</id>
<properties>
<sonar.tests>src/test/java,src/test/groovy</sonar.tests>
<sonar.exclusions>'**/*Config.java','**/*Application.java','**/*Dto.java','**/model/Q**.java'</sonar.exclusions>
</properties>
<build>
<plugins>
<!-- sonarqube -->
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.4.0.905</version>
</plugin>
<!-- jacoco -->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.1</version>
<configuration>
<append>true</append>
</configuration>
<executions>
<execution>
<id>agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-report</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
JAVA
JPA
- JPA-Create-And-Update
- Optional-Eager
- QueryDsl-Configuration
- QueryDsl-More-Type-safety
- QueryDsl-SubQuery
DDD
Install
Spring
Spring-Boot
- Swagger2-Configuration
- Spring-Restdocs-Configuration
- Spring-Page-Jackson
- JSR310-Guide
- logback-spring.xml
- WebMvcUtils.java
- Spring-Boot-Properties
- Spring-Boot-Hidden-Gems
- Spring-Boot-Config
Spring-Cloud
- Spring-Cloud-Zuul
- Spring-Cloud-Feign
- Spring-Cloud-Hystrix
- Spring-Cloud-Consul
- Spring-Cloud-Ribbon
- Spring-Cloud-Circuit-Breaker
JavaScript
Gradle
Test
Linux
Etc
TODO http://zoltanaltfatter.com/2017/06/09/publishing-domain-events-from-aggregate-roots/