빡코

[Spring-boot] JsonPathResultMatchers_Import_에러 본문

Java/Spring-boot

[Spring-boot] JsonPathResultMatchers_Import_에러

chris.djang 2020. 1. 5. 00:56

JUnit 5 

import static org.hamcrest.CoreMatchers.is;

참조: 

https://hwanud.wordpress.com/2018/09/29/junit5%EC%97%90%EC%84%9C-assertthat%EA%B3%BC-is-%EC%82%AC%EC%9A%A9/

 

 

JUnit 4 상황

 

import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; 임포트가 되었지만, 

 

이런 상황이며 

 

아래와 같은 에러메세지가 디스클로징

Testing started at 오전 12:46 ...
> Task :cleanTest
> Task :compileJava
> Task :processResources NO-SOURCE
> Task :classes
> Task :compileTestJava FAILED
C:\sts-bundle\springboot\freelec-springboot2-webservice\src\test\java\com\jojoldu\book\springboot\web\HelloControllerTest.java:44: error: incompatible types: JsonPathResultMatchers cannot be converted to ResultMatcher
                        .andExpect(jsonPath("$.name",is(name)))
                                           ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileTestJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 5s
3 actionable tasks: 3 executed

 

무엇이 문제?

그냥 수동으로 Import 해준다 .

import static org.hamcrest.Matchers.is;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;