작성
·
6.4K
3
@Parmeters를 의 값들을 받을 수 없는것 같습니다.
이런식으로 짜였는데 에러가 발생합니다.
org.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered for parameter [int basePrice] in method [public void com.hj.spring.events.EventTest.testFree(int,int,boolean)].
at org.junit.jupiter.engine.execution.ExecutableInvoker.resolveParameter(ExecutableInvoker.java:200)
at org.junit.jupiter.engine.execution.ExecutableInvoker.resolveParameters(ExecutableInvoker.java:183)
at org.junit.jupiter.engine.execution.ExecutableInvoker.resolveParameters(ExecutableInvoker.java:144)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:96)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:202)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:198)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:69)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135)
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:125)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
parameterResolver가 없다고 하는데 해결방법을 여쭐수 있을까요 junit 4.1.2버젼에 jupiter 5.5.2버젼입니다.
답변 3
15
Junit5로 할때는 방법이 조금 바뀌었습니다.
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.4.2</version>
<scope>test</scope>
</dependency>
@ParameterizedTest
@CsvSource({
"0, 0, true",
"0, 100, false",
"100, 0, false",
})
public void testFree(int basePrice, int maxPrice, boolean isFree) {
Event event = Event.builder()
.basePrice(basePrice)
.maxPrice(maxPrice)
.build();
event.update();
assertThat(event.isFree()).isEqualTo(isFree);
}
@ParameterizedTest
@MethodSource("isOffline")
public void testOffline(String location, boolean isOffline) {
Event event = Event.builder()
.location(location)
.build();
event.update();
assertThat(event.isOffline()).isEqualTo(isOffline);
}
private static Stream<Arguments> isOffline() {
return Stream.of(
Arguments.of("강남역", true),
Arguments.of(null, false),
Arguments.of("", false)
);
}
0
0
도움되었습니다 기존 @Test는 지워야하는군요! 둘다 쓰니까 계속 에러가 하나 더 나서 먼가 했내요