최대 1 분 소요

의존성 주입

dependencies {
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testImplementation 'org.junit.jupiter:junit-jupiter:5.6.0'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.6.0'
}

테스트 코드 작성

//@SpringBootTest //전체 애플리케이션 컨텍스트를 로드함
@MybatisTest //MyBatis와 관련된 빈만 로드함
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) //DataSource를 교체하지 않고 실제 연결된 DB 사용
class MyPapperTest{

    @AutoWired
    MyMapper myMapper;

    @Test
    void getMyFavorite() {
        //given
        MyVO myVO = MyVO.builder()
                .name("나카롱")
                .favorite("choco")
                .build();

        //when
        MyVO res =  this.myMapper.getMyFavorite(myVO);

        //then
        Assert.assertEquals("choco",res.getFavorite());
    }
}

카테고리:

업데이트:

댓글남기기