Skip to content

Commit

Permalink
update testing to improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Musa Rahamat committed Nov 3, 2016
1 parent f2e9c21 commit 52d8aba
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 42 deletions.
1 change: 1 addition & 0 deletions .settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ GRADLE_NATURES=org.eclipse.jdt.core.javanature
build.commands=org.eclipse.jdt.core.javabuilder
connection.arguments=
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
connection.gradle.user.home=null
connection.java.home=null
connection.jvm.arguments=
connection.project.dir=
Expand Down
26 changes: 12 additions & 14 deletions src/test/data/sandbox/empty.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<taskmanager>
<tasks>
<name>DO</name>
<startTime>now</startTime>
<endTime>no endtime</endTime>
<deadline>no deadline</deadline>
<doneStatus>true</doneStatus>
<overdueStatus>false</overdueStatus>
<newlyAdded>false</newlyAdded>
<name>test</name>
<startTime></startTime>
<endTime></endTime>
<deadline></deadline>
<doneStatus>false</doneStatus>
<favoriteStatus>true</favoriteStatus>
</tasks>
<tasks>
<name>do nothing</name>
<startTime>now</startTime>
<endTime>no endtime</endTime>
<deadline>no deadline</deadline>
<doneStatus>true</doneStatus>
<overdueStatus>false</overdueStatus>
<newlyAdded>false</newlyAdded>
<name>do sth</name>
<startTime>2016-10-25 09:00</startTime>
<endTime></endTime>
<deadline></deadline>
<doneStatus>false</doneStatus>
<favoriteStatus>false</favoriteStatus>
</tasks>
</taskmanager>
26 changes: 12 additions & 14 deletions src/test/data/sandbox/notempty.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<taskmanager>
<tasks>
<name>DO</name>
<startTime>now</startTime>
<endTime>no endtime</endTime>
<deadline>no deadline</deadline>
<doneStatus>true</doneStatus>
<overdueStatus>false</overdueStatus>
<newlyAdded>false</newlyAdded>
<name>test</name>
<startTime></startTime>
<endTime></endTime>
<deadline></deadline>
<doneStatus>false</doneStatus>
<favoriteStatus>true</favoriteStatus>
</tasks>
<tasks>
<name>do nothing</name>
<startTime>now</startTime>
<endTime>no endtime</endTime>
<deadline>no deadline</deadline>
<doneStatus>true</doneStatus>
<overdueStatus>false</overdueStatus>
<newlyAdded>false</newlyAdded>
<name>do sth</name>
<startTime>2016-10-25 09:00</startTime>
<endTime></endTime>
<deadline></deadline>
<doneStatus>false</doneStatus>
<favoriteStatus>false</favoriteStatus>
</tasks>
</taskmanager>
7 changes: 5 additions & 2 deletions src/test/java/guitests/AddCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,24 @@ public void add() {
//add one task
TestTask[] currentList = td.getTypicalTasks();
TestTask taskToAdd = TypicalTestTasks.taskH;
commandBox.runCommand("add Help Jim with his task, at 2016-10-25 9am");
assertAddSuccess(taskToAdd, currentList);
currentList = TestUtil.addTasksToList(currentList, taskToAdd);

//add another task
taskToAdd = TypicalTestTasks.taskI;
commandBox.runCommand("add Iron new clothes, by 2016-10-27 10pm");
assertAddSuccess(taskToAdd, currentList);
currentList = TestUtil.addTasksToList(currentList, taskToAdd);

//add duplicate task
commandBox.runCommand(TypicalTestTasks.taskH.getAddCommand());
commandBox.runCommand("add Help Jim with his task, at 2016-10-25 9am");
assertResultMessage(AddCommand.MESSAGE_DUPLICATE_TASK);
assertTrue(taskListPanel.isListMatching(currentList));

//add to empty list
commandBox.runCommand("clear");
commandBox.runCommand("add Accompany mom to the doctor, from 2016-10-26 2pm to 2016-10-26 5pm #gwsMum");
assertAddSuccess(TypicalTestTasks.taskA);

//invalid command
Expand All @@ -40,7 +43,7 @@ public void add() {
}

private void assertAddSuccess(TestTask taskToAdd, TestTask... currentList) {
commandBox.runCommand(taskToAdd.getAddCommand());


//confirm the new card contains the right data
TaskCardHandle addedCard = taskListPanel.navigateToTask(taskToAdd.getName().fullName);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/guitests/BackupCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void backup() {
//assertBackupCommandSuccess();

//verify a non-empty TaskManager can be backed up in a valid directory
commandBox.runCommand(TypicalTestTasks.taskH.getAddCommand());
commandBox.runCommand("add Help Jim with his task, at 2016-10-25 9am");
assertTrue(taskListPanel.isListMatching(TypicalTestTasks.taskH));
commandBox.runCommand("backup " + filepath_B);
assertResultMessage(String.format(BackupCommand.MESSAGE_BACKUP_SUCCESS, filepath_B + ".xml"));
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/guitests/ClearCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void clear() {
assertClearCommandSuccess();

//verify other commands can work after a clear command
commandBox.runCommand(TypicalTestTasks.taskH.getAddCommand());
commandBox.runCommand("add Help Jim with his task, at 2016-10-25 9am");
assertTrue(taskListPanel.isListMatching(TypicalTestTasks.taskH));
commandBox.runCommand("delete 1");
assertListSize(0);
Expand Down
12 changes: 9 additions & 3 deletions src/test/java/seedu/task/testutil/TestTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,15 @@ public String toString() {
public String getAddCommand() {
StringBuilder sb = new StringBuilder();
sb.append("add " + this.getName().fullName + "");
sb.append(", from " + this.getStartTime().value + " ");
sb.append("to " + this.getEndTime().value + " ");
sb.append("by " + this.getDeadline().value + " ");
if(!this.getStartTime().value.isEmpty()) {
sb.append(", from " + this.getStartTime().value);
}
if(!this.getEndTime().value.isEmpty()) {
sb.append(" to " + this.getEndTime().value + "");
}
if(!this.getDeadline().value.isEmpty()) {
sb.append(" by " + this.getDeadline().value + " ");
}
this.getTags().getInternalList().stream().forEach(s -> sb.append("#" + s.tagName + " "));
return sb.toString();
}
Expand Down
13 changes: 6 additions & 7 deletions src/test/java/seedu/task/testutil/TypicalTestTasks.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ public class TypicalTestTasks {
public TypicalTestTasks() {
//@@author A0147944U-reused
try {
taskA = new TaskBuilder().withName("Accompany mom to the doctor").withDeadline("2016-10-27 15:00")
.withEndTime("2016-10-26 17:00").withStartTime("2016-10-25 02:00")
.withTags("gwsMum").withStatus(false, false, false).build();
taskA = new TaskBuilder().withName("Accompany mom to the doctor").withStartTime("2016-10-26 14:00").withEndTime("2016-10-26 17:00")
.withDeadline("").withTags("gwsMum").withStatus(false, false, false).build();
taskB = new TaskBuilder().withName("Borrow software engineering book").withDeadline("2016-10-27 16:00")
.withEndTime("2016-10-26 16:00").withStartTime("2016-10-25 03:00")
.withTags("study", "seRocks").withStatus(false, false, false).build();
Expand All @@ -25,10 +24,10 @@ public TypicalTestTasks() {
taskE = new TaskBuilder().withName("Edit AddressBook file").withStartTime("2016-10-25 06:00").withEndTime("2016-10-26 13:49").withDeadline("2016-10-27 19:00").withStatus(false, false, false).build();
taskF = new TaskBuilder().withName("Finish up the project").withStartTime("2016-10-25 07:00").withEndTime("2016-10-26 13:23").withDeadline("2016-10-27 20:00").withStatus(false, false, false).build();
taskG = new TaskBuilder().withName("Go for a jog").withStartTime("2016-10-25 08:00").withEndTime("2016-10-26 12:00").withDeadline("2016-10-27 20:59").withStatus(false, false, false).build();
taskH = new TaskBuilder().withName("Help Jim with his task").withStartTime("2016-10-25 09:00").withEndTime("2016-10-26 11:00").withDeadline("2016-10-27 21:00").withStatus(false, false, false).build();
taskI = new TaskBuilder().withName("Iron new clothes").withStartTime("2016-10-25 02:59").withEndTime("2016-10-26 10:00").withDeadline("2016-10-27 22:00").withStatus(false, false, false).build();
taskJ = new TaskBuilder().withName("Accompany dad to the doctor").withDeadline("2016-10-27 15:00")
.withEndTime("2016-10-26 17:00").withStartTime("2016-10-25 02:00")
taskH = new TaskBuilder().withName("Help Jim with his task").withStartTime("2016-10-25 09:00").withEndTime("").withDeadline("").withStatus(false, false, false).build();
taskI = new TaskBuilder().withName("Iron new clothes").withStartTime("").withEndTime("").withDeadline("2016-10-27 22:00").withStatus(false, false, false).build();
taskJ = new TaskBuilder().withName("Accompany dad to the doctor").withStartTime("2016-10-26 14:00")
.withEndTime("2016-10-26 17:00").withDeadline("")
.withTags("gwsDad").withStatus(false, false, false).build();
} catch (IllegalValueException e) {
e.printStackTrace();
Expand Down

0 comments on commit 52d8aba

Please sign in to comment.