Skip to content

Commit

Permalink
test: 벌레 개수 검증 테스트에 ParameterizedTest 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
kmebin committed Nov 1, 2023
1 parent ebb1e1e commit 89163c4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions src/test/java/com/moabam/api/domain/entity/BugTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,25 @@
import static org.assertj.core.api.Assertions.*;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;

import com.moabam.global.error.exception.BadRequestException;

class BugTest {

@DisplayName("벌레 개수가 음수이면 예외가 발생한다.")
@Test
void negative_bug_count_throws_exception() {
@ParameterizedTest
@CsvSource({
"-10, 10, 10",
"10, -10, 10",
"10, 10, -10",
})
void validate_bug_count_exception(int morningBug, int nightBug, int goldenBug) {
Bug.BugBuilder bugBuilder = Bug.builder()
.morningBug(10)
.nightBug(10)
.goldenBug(-10);
.morningBug(morningBug)
.nightBug(nightBug)
.goldenBug(goldenBug);

assertThatThrownBy(bugBuilder::build)
.isInstanceOf(BadRequestException.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void get_bug_success() throws Exception {
BugResponse expected = BugMapper.toBugResponse(BugFixture.bug());
given(bugService.getBug(memberId)).willReturn(expected);

// when & then
// expected
String content = mockMvc.perform(get("/bugs"))
.andDo(print())
.andExpect(status().isOk())
Expand Down

0 comments on commit 89163c4

Please sign in to comment.