#26 pharmacy: spock - unit test

This commit is contained in:
haerong22
2022-12-12 01:02:31 +09:00
parent b972aefc79
commit 919b3b221c
2 changed files with 35 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ plugins {
id 'java'
id 'org.springframework.boot' version '2.6.7'
id 'io.spring.dependency-management' version '1.0.14.RELEASE'
id 'groovy'
}
group = 'com.example'
@@ -30,6 +31,13 @@ dependencies {
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
// spock
testImplementation 'org.spockframework:spock-core:2.3-groovy-3.0'
testImplementation 'org.spockframework:spock-spring:2.3-groovy-3.0'
// 런타임에 클래스 기반 spock mock 을 만들기 위해서 필요
testImplementation 'net.bytebuddy:byte-buddy:1.12.19'
}
tasks.named('test') {

View File

@@ -0,0 +1,27 @@
package com.example.road.api.service
import spock.lang.Specification
import java.nio.charset.StandardCharsets
class KakaoUriBuilderServiceTest extends Specification {
private KakaoUriBuilderService kakaoUriBuilderService;
def setup() {
kakaoUriBuilderService = new KakaoUriBuilderService();
}
def "buildUriByAddressSearch - 한글 파라미터의 경우 정상적으로 인코딩"() {
given:
String address = "서울 성북구"
def charset = StandardCharsets.UTF_8;
when:
def uri = kakaoUriBuilderService.builderUriByAddressSearch(address)
def decodedResult = URLDecoder.decode(uri.toString(), charset)
then:
decodedResult == "https://dapi.kakao.com/v2/local/search/address.json?query=서울 성북구"
}
}