forked from nus-cs2103-AY2122S1/ip
-
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.
Add JUnit tests to test the behavior of the code (#24)
* Add some tests for Response and Task classes
- Loading branch information
1 parent
e22e3b0
commit 2777712
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
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,15 @@ | ||
package duke; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class ResponseTest { | ||
@Test | ||
public void toString_success() { | ||
assertEquals( | ||
" ____________________________________________________________" + System.lineSeparator() | ||
+ " message" + System.lineSeparator() | ||
+ " ____________________________________________________________" | ||
, new Response("message").toString()); | ||
} | ||
} |
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,29 @@ | ||
package duke.task; | ||
|
||
import duke.Response; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class TaskTest { | ||
private static String TASK_NOT_DONE_SYMBOL = " "; | ||
private static String TASK_DONE_SYMBOL = "X"; | ||
|
||
@Test | ||
public void toString_success() { | ||
String taskDescription = "Lorem ipsum dolor sit amet"; | ||
Task task = new Task(taskDescription); | ||
assertEquals(String.format("[%s] %s", TASK_NOT_DONE_SYMBOL, taskDescription), task.toString()); | ||
task.markDone(); | ||
assertEquals(String.format("[%s] %s", TASK_DONE_SYMBOL, taskDescription), task.toString()); | ||
} | ||
|
||
@Test | ||
public void getStatusIcon_success() { | ||
String taskDescription = "Lorem ipsum dolor sit amet"; | ||
Task task = new Task(taskDescription); | ||
assertEquals(TASK_NOT_DONE_SYMBOL, task.getStatusIcon()); | ||
task.markDone(); | ||
assertEquals(TASK_DONE_SYMBOL, task.getStatusIcon()); | ||
} | ||
} |