Skip to content

Commit

Permalink
Add JUnit tests to test the behavior of the code (#24)
Browse files Browse the repository at this point in the history
* Add some tests for Response and Task classes
  • Loading branch information
Anonymxtrix committed Aug 31, 2021
1 parent e22e3b0 commit 2777712
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/test/java/duke/ResponseTest.java
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());
}
}
29 changes: 29 additions & 0 deletions src/test/java/duke/task/TaskTest.java
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());
}
}

0 comments on commit 2777712

Please sign in to comment.