• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    미해결

안녕하세요 강사님

20.12.10 21:51 작성 조회수 296

0

테스트 관련 강의를 보다가

OutputCapture를 테스트 해보려고헀는데 하기와 같은 에러가 발생해서 질문드리고싶습니다..

Test Source

package me.survivalking.spring_test;

import me.survivalking.spring_test.sample.SampleController;
import me.survivalking.spring_test.sample.SampleService;
import org.junit.Rule;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.boot.test.system.OutputCaptureRule;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.reactive.server.WebTestClient;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureMockMvc
@AutoConfigureWebTestClient
class SpringTestApplicationTests {
// WebEnvironment Mock일 떄 사용
@Autowired
private MockMvc mockMvc;

@Autowired
private TestRestTemplate testRestTemplate;

//Controller단만 가서 확인하고 싶다
@MockBean
SampleService sampleService;

// 위에 것들은 Sync 방식 WebClient Async 응답이 오면 Callback이 옴 나머지는 기다림
@Autowired
WebTestClient webTestClient;

@Rule
public OutputCaptureRule outputCapture = new OutputCaptureRule();


//@Test
public void contextLoads() throws Exception{
mockMvc.perform(MockMvcRequestBuilders.get("/hello"))
.andExpect(status().isOk())
.andExpect(content().string("hello heesuk"))
.andDo(print());
}

//@Test
public void Test2() throws Exception{
String result = testRestTemplate.getForObject("/hello", String.class);
assertThat(result).isEqualTo("hello heesuk");
}

//@Test
public void Test3() throws Exception{
when(sampleService.getName()).thenReturn("heesuk");

String result = testRestTemplate.getForObject("/hello",String.class);
assertThat(result).isEqualTo("hello heesuk");
}

@Test
public void Test4() throws Exception{
when(sampleService.getName()).thenReturn("heesuk");

webTestClient.get().uri("/hello").exchange()
.expectStatus().isOk()
.expectBody(String.class).isEqualTo("hello heesuk");

assertThat(outputCapture.toString())
.contains("holoman")
.contains("skip");
}
}

OutputCapture가 - 표시가 되어있어서 OutputCaptureRule을 사용헀더니 하기와 같은 에러가 나옵니다.

Connected to the target VM, address: '127.0.0.1:13028', transport: 'socket'

21:50:12.485 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]

21:50:12.510 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]

21:50:12.557 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [me.survivalking.spring_test.SpringTestApplicationTests] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper]

21:50:12.572 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [me.survivalking.spring_test.SpringTestApplicationTests], using SpringBootContextLoader

21:50:12.577 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [me.survivalking.spring_test.SpringTestApplicationTests]: class path resource [me/survivalking/spring_test/SpringTestApplicationTests-context.xml] does not exist

21:50:12.578 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [me.survivalking.spring_test.SpringTestApplicationTests]: class path resource [me/survivalking/spring_test/SpringTestApplicationTestsContext.groovy] does not exist

21:50:12.578 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [me.survivalking.spring_test.SpringTestApplicationTests]: no resource found for suffixes {-context.xml, Context.groovy}.

21:50:12.579 [main] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [me.survivalking.spring_test.SpringTestApplicationTests]: SpringTestApplicationTests does not declare any static, non-private, non-final, nested classes annotated with @Configuration.

21:50:12.662 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [me.survivalking.spring_test.SpringTestApplicationTests]

21:50:12.758 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: file [D:\Spring_Pjt\IntelliJ_WorkSpace\spring_test\target\classes\me\survivalking\spring_test\SpringTestApplication.class]

21:50:12.760 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Found @SpringBootConfiguration me.survivalking.spring_test.SpringTestApplication for test class me.survivalking.spring_test.SpringTestApplicationTests

21:50:12.863 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - @TestExecutionListeners is not present for class [me.survivalking.spring_test.SpringTestApplicationTests]: using defaults.

21:50:12.864 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener]

21:50:12.877 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Skipping candidate TestExecutionListener [org.springframework.test.context.transaction.TransactionalTestExecutionListener] due to a missing dependency. Specify custom listener classes or make the default listener classes and their required dependencies available. Offending class: [org/springframework/transaction/interceptor/TransactionAttributeSource]

21:50:12.877 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Skipping candidate TestExecutionListener [org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener] due to a missing dependency. Specify custom listener classes or make the default listener classes and their required dependencies available. Offending class: [org/springframework/transaction/interceptor/TransactionAttribute]

21:50:12.878 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@cb191ca, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@42f48531, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@a776e, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@792bbc74, org.springframework.test.context.support.DirtiesContextTestExecutionListener@79145d5a, org.springframework.test.context.event.EventPublishingTestExecutionListener@1f2f9244, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@4c4d27c8, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@6821ea29, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@338494fa, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@505a9d7c, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@758c83d8, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener@129b4fe2]

21:50:12.884 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext@e077866 testClass = SpringTestApplicationTests, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@ed3068a testClass = SpringTestApplicationTests, locations = '{}', classes = '{class me.survivalking.spring_test.SpringTestApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true, server.port=0}', contextCustomizers = set[[ImportsContextCustomizer@7c2b6087 key = [org.springframework.boot.test.autoconfigure.web.servlet.MockMvcAutoConfiguration, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcWebClientAutoConfiguration, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcWebDriverAutoConfiguration, org.springframework.boot.autoconfigure.security.oauth2.client.servlet.OAuth2ClientAutoConfiguration, org.springframework.boot.autoconfigure.security.oauth2.resource.servlet.OAuth2ResourceServerAutoConfiguration, org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration, org.springframework.boot.autoconfigure.security.servlet.SecurityFilterAutoConfiguration, org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcSecurityConfiguration, org.springframework.boot.autoconfigure.security.oauth2.client.reactive.ReactiveOAuth2ClientAutoConfiguration, org.springframework.boot.autoconfigure.security.oauth2.resource.reactive.ReactiveOAuth2ResourceServerAutoConfiguration, org.springframework.boot.autoconfigure.security.reactive.ReactiveSecurityAutoConfiguration, org.springframework.boot.autoconfigure.security.reactive.ReactiveUserDetailsServiceAutoConfiguration, org.springframework.boot.test.autoconfigure.web.reactive.WebTestClientAutoConfiguration]], org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@5026735c, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@10f7f7de, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@383e320a, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@488d1cd7, org.springframework.boot.test.web.reactive.server.WebTestClientContextCustomizer@d278d2b, org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer@6e005dc9, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@3794467c, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@82ea68c, org.springframework.boot.test.context.SpringBootTestArgs@1, org.springframework.boot.test.context.SpringBootTestWebEnvironment@eb21112], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> false]], class annotated with @DirtiesContext [false] with mode [null].

21:50:12.926 [main] DEBUG org.springframework.test.context.support.TestPropertySourceUtils - Adding inlined properties to environment: {spring.jmx.enabled=false, org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true, server.port=0}

  .   ____          _            __ _ _

 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \

( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \

 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )

  '  |____| .__|_| |_|_| |_\__, | / / / /

 =========|_|==============|___/=/_/_/_/

 :: Spring Boot ::                (v2.4.0)

2020-12-10 21:50:13.200  INFO 6952 --- [           main] m.s.s.SpringTestApplicationTests         : Starting SpringTestApplicationTests using Java 1.8.0_261 on DESKTOP-4OCTHFN with PID 6952 (started by uesr in D:\Spring_Pjt\IntelliJ_WorkSpace\spring_test)

2020-12-10 21:50:13.206  INFO 6952 --- [           main] m.s.s.SpringTestApplicationTests         : No active profile set, falling back to default profiles: default

2020-12-10 21:50:14.743  INFO 6952 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 0 (http)

2020-12-10 21:50:14.754  INFO 6952 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]

2020-12-10 21:50:14.755  INFO 6952 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.39]

2020-12-10 21:50:14.864  INFO 6952 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext

2020-12-10 21:50:14.864  INFO 6952 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1637 ms

2020-12-10 21:50:15.282  INFO 6952 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'

2020-12-10 21:50:15.666  INFO 6952 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring TestDispatcherServlet ''

2020-12-10 21:50:15.666  INFO 6952 --- [           main] o.s.t.web.servlet.TestDispatcherServlet  : Initializing Servlet ''

2020-12-10 21:50:15.667  INFO 6952 --- [           main] o.s.t.web.servlet.TestDispatcherServlet  : Completed initialization in 1 ms

2020-12-10 21:50:15.730  INFO 6952 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 13033 (http) with context path ''

2020-12-10 21:50:15.740  INFO 6952 --- [           main] m.s.s.SpringTestApplicationTests         : Started SpringTestApplicationTests in 2.811 seconds (JVM running for 4.224)

2020-12-10 21:50:16.576  INFO 6952 --- [o-auto-1-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'

2020-12-10 21:50:16.577  INFO 6952 --- [o-auto-1-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'

2020-12-10 21:50:16.577  INFO 6952 --- [o-auto-1-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 0 ms

2020-12-10 21:50:16.594  INFO 6952 --- [o-auto-1-exec-1] m.s.spring_test.sample.SampleController  : holoman

skip

java.lang.IllegalStateException: No system captures found. Please check your output capture registration.

at org.springframework.util.Assert.state(Assert.java:76)

at org.springframework.boot.test.system.OutputCapture.get(OutputCapture.java:129)

at org.springframework.boot.test.system.OutputCapture.getAll(OutputCapture.java:100)

at org.springframework.boot.test.system.OutputCapture.toString(OutputCapture.java:90)

at org.springframework.boot.test.system.OutputCaptureRule.toString(OutputCaptureRule.java:101)

at me.survivalking.spring_test.SpringTestApplicationTests.Test4(SpringTestApplicationTests.java:82)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:688)

at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)

at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)

at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)

at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)

at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)

at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)

at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)

at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)

at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)

at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)

at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)

at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)

at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)

at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:210)

at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)

at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:206)

at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:131)

at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:65)

at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)

at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)

at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)

at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)

at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)

at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)

at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)

at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)

at java.util.ArrayList.forEach(ArrayList.java:1259)

at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)

at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)

at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)

at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)

at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)

at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)

at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)

at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)

at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)

at java.util.ArrayList.forEach(ArrayList.java:1259)

at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)

at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)

at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)

at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)

at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)

at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)

at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)

at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)

at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)

at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)

at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)

at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)

at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108)

at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)

at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)

at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)

at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)

at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96)

at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75)

at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71)

at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)

at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220)

at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)

2020-12-10 21:50:18.898  INFO 6952 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'applicationTaskExecutor'

Disconnected from the target VM, address: '127.0.0.1:13028', transport: 'socket'

Process finished with exit code -1

어떤부분이 잘못되었거나.. 잘못사용됬을까요.. 궁금합니다.

답변 3

·

답변을 작성해보세요.

0

spring boot parent에서 수정하는게 아니라 김김희석님의 프로젝트에서 버전을 변경해야죠.
스프링 부트 강의의 의존성 관련된 수업에서 다뤘으니까 다시 한번 확인해 보세요.

0

감사합니다 강사님

혹시 junit5를 사용하지않고 4를 사용하도록 pom에서 제어가 가능한가요?

spring boot parent 의 junit관련 dependency를 수정한다던가하는 방식으로

0

최근 스프링 부트는 JUnit 5를 기본으로 쓰는데 제가 이 강의를 만들 시점에는 JUnit 4를 쓰던 시절이었습니다. (2년전) 그래서.. 지지금 테스트 코드를 보면 JUnit 4 코드로 작성하셨는데 실제로는 JUnit 5를 쓰니까 @Rule과 @RunWith 같은건 무시된거죠. Junit 5 학습도 하시고 (더 자바, 테스트 강의) 스프링 부트 최신 버전도 학습 (스프링 부트 업데이트 강의)을 하시는게 정석적인 접근 방법이지만 당장 이 문제만 해결하고 싶으시다면 이렇게 해보세요.

@RegisterExtension
OutputCapture output = new OutputCapture();