-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
73fe28b
commit fabf82b
Showing
4 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
장채은/test-driven/src/test/java/testdriven/chap05/BadTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package testdriven.chap05; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.File; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class BadTest { | ||
// private FileOperator op = new FileOperator(); | ||
// private static File file; | ||
// | ||
// @Test | ||
// void fileCreationTest(){ | ||
// File createdFile = op.createFile(); // 파일 생성 | ||
// assertTrue(createdFile.length()>0); | ||
// this.file = createdFile; | ||
// } | ||
// | ||
// @Test | ||
// void readFileTest(){ | ||
// long data = op.readData(file); // fileCreationTest에서 생성한 파일 사용 | ||
// assertTrue(data>0); | ||
// } | ||
} |
26 changes: 26 additions & 0 deletions
26
장채은/test-driven/src/test/java/testdriven/chap05/DisplayNameTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package testdriven.chap05; | ||
|
||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
@DisplayName(("@DisplayName 테스트")) | ||
public class DisplayNameTest { | ||
@DisplayName("값이 같은지 비교") | ||
@Test | ||
void assertEqualsMethod(){ | ||
|
||
} | ||
|
||
@DisplayName("익셉션 발생 여부 테스트") // 테스트 메모 | ||
@Test | ||
void assertThrowsTest(){ | ||
|
||
} | ||
|
||
@Disabled // 특정 테스트 실행하고 싶지 않을 때 | ||
@Test | ||
void failMethod(){ | ||
|
||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
장채은/test-driven/src/test/java/testdriven/chap05/LifecycleTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package testdriven.chap05; | ||
|
||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class LifecycleTest { | ||
public LifecycleTest(){ | ||
System.out.println("new LifecycleTest"); | ||
} | ||
|
||
// 각각 테스트 하나 진행 시작할 때 호출되는 메소드 | ||
@BeforeEach | ||
void setUp(){ | ||
System.out.println("setUp"); | ||
} | ||
|
||
@Test | ||
void a(){ | ||
System.out.println("A"); | ||
} | ||
|
||
@Test | ||
void b(){ | ||
System.out.println("B"); | ||
} | ||
|
||
// 각각 테스트 하나 진행 끝날 때 호출되는 메소드 | ||
@AfterEach | ||
void tearDown(){ | ||
System.out.println("tearDown"); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
장채은/test-driven/src/test/java/testdriven/chap05/TestMethod.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package testdriven.chap05; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.time.LocalDate; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public class TestMethod { | ||
@Test | ||
void assertEqualsMethod(){ | ||
LocalDate localDate = LocalDate.now(); | ||
LocalDate localDate1 = LocalDate.now(); | ||
assertEquals(localDate, localDate1); | ||
} | ||
|
||
@Test | ||
void assertEqualsMethod2(){ | ||
assertEquals(3, 5/2); // 에러 발생시, 검증 코드 실패로 | ||
assertEquals(4, 2*2); // 이 코드 실행 되지 않음 | ||
} | ||
|
||
// @Test | ||
// void failMethod(){ | ||
// try{ | ||
// AuthService authService = new AuthService(); | ||
// authService.authenticate(null, null); // null 이 발생했는데, 익셉션이 발생하지 않으면 테스트 실패 (null == null) | ||
// fail(); | ||
// }catch (IllegalArgumentException e){ | ||
// | ||
// } | ||
// } | ||
// | ||
// @Test | ||
// void assertThrowsMethod(){ | ||
// IllegalArgumentException e = assertThrows(IllegalStateException.class, | ||
// ()->{ | ||
// AuthService authService = new AuthService(); | ||
// authService.authenticate(null, null); | ||
// }); | ||
// | ||
// assertTrue(e.getMessage().contains("id")); | ||
// } | ||
|
||
@Test | ||
void assertAllMethod(){ | ||
assertAll( | ||
() -> assertEquals(3, 5/2), | ||
() -> assertEquals(4, 2*2), | ||
() -> assertEquals(6, 11/2) | ||
); | ||
} | ||
} |