Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

매개변수화된 테스트 작성을 위한 의존성 추가 및 테스트 코드 리팩토링😊 #33

Merged
merged 3 commits into from
Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions yoonexample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@ repositories {
mavenCentral()
}

test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
}

dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.2'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.6.2'
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.6.2'
testImplementation 'org.assertj:assertj-core:3.16.1'
}
78 changes: 78 additions & 0 deletions yoonexample/src/test/java/heap/SimpleHeapTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package heap;

import static org.assertj.core.api.Assertions.assertThat;

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;

class SimpleHeapTest {

@Test
@DisplayName("힙의_초기화_테스트")
void 힙의_초기화_테스트() {
SimpleHeap<Character> charHeap = new ArraySimpleHeap<>();

assertThat(charHeap).isNotNull();
assertThat(charHeap.isEmpty()).isTrue();
}

@ParameterizedTest
@CsvSource({"'A','B','C'"})
@DisplayName("힙_저장_테스트")
void 힙_저장_테스트(char firstElem, char secondElem, char thirdElem) {
SimpleHeap<Character> charHeap = new ArraySimpleHeap<>();

charHeap.insert(firstElem, 1);
charHeap.insert(secondElem, 2);
charHeap.insert(thirdElem, 3);

assertThat(charHeap).isNotNull();
assertThat(charHeap.isEmpty()).isFalse();
}

@ParameterizedTest
@CsvSource({"'A','B','C'"})
@DisplayName("힙_저장_후_제거_테스트")
void 힙_저장_후_제거_테스트(char firstElem, char secondElem, char thirdElem) {
SimpleHeap<Character> charHeap = new ArraySimpleHeap<>();

charHeap.insert(firstElem, 1);
charHeap.insert(secondElem, 2);
charHeap.insert(thirdElem, 3);

assertThat(charHeap).isNotNull();
assertThat(charHeap.isEmpty()).isFalse();
assertThat(charHeap.delete()).isEqualTo(firstElem);
assertThat(charHeap.delete()).isEqualTo(secondElem);
assertThat(charHeap.delete()).isEqualTo(thirdElem);
assertThat(charHeap.isEmpty()).isTrue();
}

@ParameterizedTest
@CsvSource({"'A','B','C'"})
@DisplayName("힙_사용_테스트")
void 힙_사용_테스트(char firstElem, char secondElem, char thirdElem) {
SimpleHeap<Character> charHeap = new ArraySimpleHeap<>();

charHeap.insert(firstElem, 1);
charHeap.insert(secondElem, 2);
charHeap.insert(thirdElem, 3);

assertThat(charHeap.delete()).isEqualTo('A');

charHeap.insert(firstElem, 1);
charHeap.insert(secondElem, 2);
charHeap.insert(thirdElem, 3);

assertThat(charHeap).isNotNull();
assertThat(charHeap.isEmpty()).isFalse();
assertThat(charHeap.delete()).isEqualTo(firstElem);
assertThat(charHeap.delete()).isEqualTo(secondElem);
assertThat(charHeap.delete()).isEqualTo(secondElem);
assertThat(charHeap.delete()).isEqualTo(thirdElem);
assertThat(charHeap.delete()).isEqualTo(thirdElem);
assertThat(charHeap.isEmpty()).isTrue();
}
}
Loading