Skip to content
This repository has been archived by the owner on Mar 5, 2023. It is now read-only.

Commit

Permalink
ClearCommandTest: fix tautological tests
Browse files Browse the repository at this point in the history
Tests in ClearCommandTest always pass because the actual and expected
model refer to the same instance;
`assertEquals(expectedModel, actualModel)` is always true because
expectedModel and actualModel reference the same object.

As a result, the model's state isn't correctly verified.

Let's update these tests to correctly verify the model's state.
  • Loading branch information
Zhiyuan-Amos committed Aug 9, 2018
1 parent 6ae9591 commit c9b222c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/test/java/seedu/address/logic/commands/ClearCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.junit.Test;

import seedu.address.logic.CommandHistory;
import seedu.address.model.AddressBook;
import seedu.address.model.Model;
import seedu.address.model.ModelManager;
import seedu.address.model.UserPrefs;
Expand All @@ -15,13 +16,20 @@ public class ClearCommandTest {
@Test
public void execute_emptyAddressBook_success() {
Model model = new ModelManager();
assertCommandSuccess(prepareCommand(model), model, ClearCommand.MESSAGE_SUCCESS, model);
Model expectedModel = new ModelManager();
expectedModel.commitAddressBook();

assertCommandSuccess(prepareCommand(model), model, ClearCommand.MESSAGE_SUCCESS, expectedModel);
}

@Test
public void execute_nonEmptyAddressBook_success() {
Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs());
assertCommandSuccess(prepareCommand(model), model, ClearCommand.MESSAGE_SUCCESS, model);
Model expectedModel = new ModelManager(getTypicalAddressBook(), new UserPrefs());
expectedModel.resetData(new AddressBook());
expectedModel.commitAddressBook();

assertCommandSuccess(prepareCommand(model), model, ClearCommand.MESSAGE_SUCCESS, expectedModel);
}

/**
Expand Down

0 comments on commit c9b222c

Please sign in to comment.