작성
·
1.8K
1
import hello.core.AppConfig;
import hello.core.member.MemberService;
import hello.core.member.MemberServiceImpl;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import static org.assertj.core.api.Assertions.*;
//ctrl + e 이전코드로 가기
class ApplicationContextBasicFindTest {
AnnotationConfigApplicationContext ac = new AnnotationConfigApplicationContext(AppConfig.class);
@Test
@DisplayName("빈 이름으로 조회")
void findBeanByName() {
MemberService memberService = ac.getBean("memberService",MemberService.class);
Assertions
//assertThat(memberService).isInstanceOf(MemberServiceImpl.class);
}
}
답변 4
1
안녕하세요. 사탕님
확인해보니
ApplicationContextBasicFindTest의 위치가 src/main 하위에 있더라구요.
테스트용 클래스는 src/test 하위에 있어야 합니다^^
테스트 클레스들을 이동해주시면 정상 동작할거에요.
감사합니다.
0
0
plugins {
id 'org.springframework.boot' version '2.4.3'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
group = 'hello'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'junit:junit:4.12'
implementation 'org.junit.jupiter:junit-jupiter:5.4.2'
testImplementation ('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}
test {
useJUnitPlatform()
}
어떤거를 추가해야 되지요??
0
// https://mvnrepository.com/artifact/org.assertj/assertj-core
testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.19.0'
이걸해도 소용없네요
보냇습니다