-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add unit tests for ViewAllCommand and ViewCommand classes #111 #131
Changes from 15 commits
20e25f1
017b996
9d049e3
f97c6b1
e942a7e
42f0c7f
b414b98
7140ae2
5457976
ffd7b0f
8b3d3a3
2486c44
2d1260d
73147c3
915c4d9
acfb6a3
ea54ab7
3a068e6
2d4cf4f
3048a59
ea22dbf
5334baf
defefe1
4d30dde
d64b9f4
261fcab
fe3fa09
b01b1e6
39ad9a7
d6a6987
d2e9c4d
449af76
5fcc198
f565130
f6c2d90
f584b82
2a11bd5
beef8ab
c3af8e8
9c60233
b9db7e5
5b654c4
b4aba03
eb7f500
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
package seedu.addressbook.commands; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import seedu.addressbook.common.Messages; | ||
import seedu.addressbook.data.AddressBook; | ||
import seedu.addressbook.data.person.Address; | ||
import seedu.addressbook.data.person.Email; | ||
import seedu.addressbook.data.person.Name; | ||
import seedu.addressbook.data.person.Person; | ||
import seedu.addressbook.data.person.Phone; | ||
import seedu.addressbook.data.person.ReadOnlyPerson; | ||
import seedu.addressbook.data.tag.UniqueTagList; | ||
import seedu.addressbook.util.TestUtil; | ||
import seedu.addressbook.util.TypicalPersons; | ||
|
||
import static seedu.addressbook.util.TestUtil.assertCommandResult; | ||
|
||
public class ViewAllCommandTest { | ||
private AddressBook addressBook; | ||
private AddressBook emptyAddressBook; | ||
private List<ReadOnlyPerson> emptyDisplayList; | ||
private List<ReadOnlyPerson> listWithAll; | ||
private List<ReadOnlyPerson> listWithSome; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
TypicalPersons td = new TypicalPersons(); | ||
|
||
emptyAddressBook = TestUtil.createAddressBook(); | ||
addressBook = td.getTypicalAddressBook(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same for this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment was intended for the line below. Sorry. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also note #134 |
||
|
||
emptyDisplayList = TestUtil.createList(); | ||
listWithAll = td.getListWithAllPersons(); | ||
listWithSome = td.getListWithSomePersons(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On a related note, lines 32, 35, 38, 39, should have been put together as they are connected. i.e. declaring a variable and then using it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. noted |
||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extract into a |
||
|
||
@Test | ||
public void viewAllCommand_invalidIndex_returnsInvalidIndexMessage() { | ||
// empty addressbook | ||
assertViewAllErrorInvalidIndex(emptyAddressBook, emptyDisplayList, 1); | ||
|
||
// non-empty addressbook | ||
assertViewAllErrorInvalidIndex(addressBook, listWithAll, -1); | ||
assertViewAllErrorInvalidIndex(addressBook, listWithAll, 0); | ||
assertViewAllErrorInvalidIndex(addressBook, listWithAll, listWithAll.size() + 1); | ||
} | ||
|
||
@Test | ||
public void viewAllCommand_personNotInAddressBook_returnsPersonNotInAddressBookMessage() throws Exception { | ||
// generate person not in addressbook, add to displayList | ||
Person someone = new Person(new Name("me"), | ||
new Phone("123", true), | ||
new Email("[email protected]", true), | ||
new Address("nus", false), | ||
new UniqueTagList(Collections.emptySet())); | ||
listWithAll.add(someone); | ||
|
||
// empty addressbook | ||
assertViewAllErrorPersonNotInAddressBook(emptyAddressBook, listWithAll, 1); | ||
|
||
// non-empty addressbook | ||
assertViewAllErrorPersonNotInAddressBook(addressBook, listWithAll, listWithAll.size()); | ||
} | ||
|
||
@Test | ||
public void viewAllCommand_validIndex_returnsPersonDetails() { | ||
// person with no private information | ||
assertViewAllSuccess(addressBook, listWithAll, 1); | ||
|
||
// person with some private information | ||
assertViewAllSuccess(addressBook, listWithAll, 2); | ||
|
||
// addressbook has more people than displayList | ||
assertViewAllSuccess(addressBook, listWithSome, 1); | ||
} | ||
|
||
/** | ||
* Creates a new ViewAll command. | ||
*/ | ||
private Command generateViewAllCommand(AddressBook addressBook, List<ReadOnlyPerson> displayList, int index) { | ||
Command command = new ViewAllCommand(index); | ||
command.setData(addressBook, displayList); | ||
|
||
return command; | ||
} | ||
|
||
/** | ||
* Asserts that the details person at specific index can be successfully retrieved | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
* and displayed. | ||
*/ | ||
private void assertViewAllSuccess(AddressBook addressBook, List<ReadOnlyPerson> list, int index) { | ||
String expectedMessage = String.format(ViewAllCommand.MESSAGE_VIEW_PERSON_DETAILS, | ||
list.get(index - 1).getAsTextShowAll()); | ||
|
||
Command command = generateViewAllCommand(addressBook, list, index); | ||
assertCommandResult(command, expectedMessage, addressBook, TestUtil.clone(addressBook)); | ||
} | ||
|
||
/** | ||
* Asserts that the details of person at specific index cannot be retrieved due to | ||
* invalid index. | ||
*/ | ||
private void assertViewAllErrorInvalidIndex(AddressBook addressBook, List<ReadOnlyPerson> list, int index) { | ||
String expectedMessage = Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX; | ||
|
||
Command command = generateViewAllCommand(addressBook, list, index); | ||
assertCommandResult(command, expectedMessage, addressBook, TestUtil.clone(addressBook)); | ||
} | ||
|
||
/** | ||
* Asserts that the details of person at specific index cannot be retrieved due to | ||
* person not existing in the addressbook. | ||
*/ | ||
private void assertViewAllErrorPersonNotInAddressBook(AddressBook addressBook, List<ReadOnlyPerson> list, int index) { | ||
String expectedMessage = Messages.MESSAGE_PERSON_NOT_IN_ADDRESSBOOK; | ||
|
||
Command command = generateViewAllCommand(addressBook, list, index); | ||
assertCommandResult(command, expectedMessage, addressBook, TestUtil.clone(addressBook)); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can the common part of the above two methods can be extracted as a method? |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
package seedu.addressbook.commands; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import seedu.addressbook.common.Messages; | ||
import seedu.addressbook.data.AddressBook; | ||
import seedu.addressbook.data.person.Address; | ||
import seedu.addressbook.data.person.Email; | ||
import seedu.addressbook.data.person.Name; | ||
import seedu.addressbook.data.person.Person; | ||
import seedu.addressbook.data.person.Phone; | ||
import seedu.addressbook.data.person.ReadOnlyPerson; | ||
import seedu.addressbook.data.tag.UniqueTagList; | ||
import seedu.addressbook.util.TestUtil; | ||
import seedu.addressbook.util.TypicalPersons; | ||
|
||
import static seedu.addressbook.util.TestUtil.assertCommandResult; | ||
|
||
public class ViewCommandTest { | ||
private AddressBook addressBook; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmph, we can't use So, I think you should just add this in to your PR: diff --git a/test/java/seedu/addressbook/util/TestUtil.java b/test/java/seedu/addressbook/util/TestUtil.java
index 8f4eaf8..a1f0836 100644
--- a/test/java/seedu/addressbook/util/TestUtil.java
+++ b/test/java/seedu/addressbook/util/TestUtil.java
@@ -26,13 +26,16 @@ import seedu.addressbook.data.tag.UniqueTagList;
public class TestUtil {
/**
* Creates an address book containing the given persons.
- * @throws DuplicatePersonException if two or more given persons are the same
*/
- public static AddressBook createAddressBook(Person... persons) throws DuplicatePersonException {
+ public static AddressBook createAddressBook(Person... persons) {
AddressBook addressBook = new AddressBook();
for (Person person : persons) {
- addressBook.addPerson(person);
+ try {
+ addressBook.addPerson(person);
+ } catch (DuplicatePersonException e) {
+ throw new AssertionError(e);
+ }
}
return addressBook; No point letting the quality of your PR suffer just because the code base just happens to be like this already. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, maybe name this |
||
private AddressBook emptyAddressBook; | ||
private List<ReadOnlyPerson> emptyDisplayList; | ||
private List<ReadOnlyPerson> listWithAll; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. May be useful to name this lists so that first-time readers will know what they will be used for. e.g. |
||
private List<ReadOnlyPerson> listWithSome; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
TypicalPersons td = new TypicalPersons(); | ||
|
||
emptyAddressBook = TestUtil.createAddressBook(); | ||
addressBook = td.getTypicalAddressBook(); | ||
|
||
emptyDisplayList = TestUtil.createList(); | ||
listWithAll = td.getListWithAllPersons(); | ||
listWithSome = td.getListWithSomePersons(); | ||
} | ||
|
||
@Test | ||
public void viewCommand_invalidIndex_returnsInvalidIndexMessage() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
// empty addressbook | ||
assertViewErrorInvalidIndex(emptyAddressBook, emptyDisplayList, 1); | ||
|
||
// non-empty addressbook | ||
assertViewErrorInvalidIndex(addressBook, listWithAll, -1); | ||
assertViewErrorInvalidIndex(addressBook, listWithAll, 0); | ||
assertViewErrorInvalidIndex(addressBook, listWithAll, listWithAll.size() + 1); | ||
} | ||
|
||
@Test | ||
public void viewCommand_personNotInAddressBook_returnsPersonNotInAddressBookMessage() throws Exception { | ||
// generate person not in addressbook, add to displayList | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More descriptive: |
||
Person someone = new Person(new Name("me"), | ||
new Phone("123", true), | ||
new Email("[email protected]", true), | ||
new Address("nus", false), | ||
new UniqueTagList(Collections.emptySet())); | ||
listWithAll.add(someone); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This goes against how I think you should just define a local variable for this. |
||
|
||
// empty addressbook | ||
assertViewErrorPersonNotInAddressBook(emptyAddressBook, listWithAll, 1); | ||
|
||
// non-empty addressbook | ||
assertViewErrorPersonNotInAddressBook(addressBook, listWithAll, listWithAll.size()); | ||
} | ||
|
||
@Test | ||
public void viewCommand_validIndex_returnsPersonDetails() { | ||
// person with no private information | ||
assertViewSuccess(addressBook, listWithAll, 1); | ||
|
||
// person with some private information | ||
assertViewSuccess(addressBook, listWithAll, 2); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need a person with all info private, to confirm that 'privacy' works for each relevant field. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @damithc In There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I meant such a person must be included as one of the test cases in this method. Your comment in line 74 says There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh, I get it |
||
|
||
// addressbook has more people than displayList | ||
assertViewSuccess(addressBook, listWithSome, 1); | ||
} | ||
|
||
/** | ||
* Creates a new view command. | ||
*/ | ||
private Command generateViewCommand(AddressBook addressBook, List<ReadOnlyPerson> displayList, int index) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why If you prefer the name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, |
||
ViewCommand command = new ViewCommand(index); | ||
command.setData(addressBook, displayList); | ||
|
||
return command; | ||
} | ||
|
||
/** | ||
* Asserts that the details person at specific index can be successfully retrieved | ||
* and displayed. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also add |
||
*/ | ||
private void assertViewSuccess(AddressBook addressBook, List<ReadOnlyPerson> list, int index) { | ||
String expectedMessage = String.format(ViewCommand.MESSAGE_VIEW_PERSON_DETAILS, | ||
list.get(index - 1).getAsTextHidePrivate()); | ||
|
||
Command command = generateViewCommand(addressBook, list, index); | ||
assertCommandResult(command, expectedMessage, addressBook, TestUtil.clone(addressBook)); | ||
} | ||
|
||
/** | ||
* Asserts that the details of person at specific index cannot be retrieved due to | ||
* invalid index. | ||
*/ | ||
private void assertViewErrorInvalidIndex(AddressBook addressBook, List<ReadOnlyPerson> list, int index) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this really need its own method? Yes, I know the alternative is repeating If the reason is because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If inline this method and put Message into the test case, does it really make sense or help improve readability? eg. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Doesn't your test name already say
OK then. |
||
String expectedMessage = Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX; | ||
|
||
Command command = generateViewCommand(addressBook, list, index); | ||
assertCommandResult(command, expectedMessage, addressBook, TestUtil.clone(addressBook)); | ||
} | ||
|
||
/** | ||
* Asserts that the details of person at specific index cannot be retrieved due to | ||
* person not existing in the addressbook. | ||
*/ | ||
private void assertViewErrorPersonNotInAddressBook(AddressBook addressBook, List<ReadOnlyPerson> list, int index) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this really need its own method? Same reasoning as |
||
String expectedMessage = Messages.MESSAGE_PERSON_NOT_IN_ADDRESSBOOK; | ||
|
||
Command command = generateViewCommand(addressBook, list, index); | ||
assertCommandResult(command, expectedMessage, addressBook, TestUtil.clone(addressBook)); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this class is almost the same as the other test class, we can text both commands in one of the class and make the other class empty with just a comment to explain why it is empty. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ | |
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import seedu.addressbook.commands.Command; | ||
import seedu.addressbook.commands.CommandResult; | ||
import seedu.addressbook.data.AddressBook; | ||
import seedu.addressbook.data.exception.IllegalValueException; | ||
import seedu.addressbook.data.person.Address; | ||
|
@@ -75,4 +77,18 @@ public static void assertTextFilesEqual(Path path1, Path path2) throws IOExcepti | |
List<String> list2 = Files.readAllLines(path2, Charset.defaultCharset()); | ||
assertEquals(String.join("\n", list1), String.join("\n", list2)); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary change. |
||
/** | ||
* Executes the command, and asserts the result message is as expected. | ||
*/ | ||
public static void assertCommandResult(Command command, String expectedMessage, AddressBook addressBook, | ||
AddressBook expectedAddressBook) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More readable indentation: public static void assertCommandResult(Command command, String expectedMessage, AddressBook addressBook,
AddressBook expectedAddressBook) { |
||
CommandResult result = command.execute(); | ||
|
||
// asserts the result message is correct as expected | ||
assertEquals(expectedMessage, result.feedbackToUser); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we be comparing the For example, we may wish to check that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, that's actually better. I don't mind leaving it as a TODO though. |
||
|
||
// TODO: overwrite equals method in AddressBook and replace with equals method below | ||
assertEquals(addressBook.getAllPersons(), expectedAddressBook.getAllPersons()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
package seedu.addressbook.util; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extra space |
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import seedu.addressbook.data.AddressBook; | ||
import seedu.addressbook.data.exception.IllegalValueException; | ||
|
@@ -7,47 +10,65 @@ | |
import seedu.addressbook.data.person.Name; | ||
import seedu.addressbook.data.person.Person; | ||
import seedu.addressbook.data.person.Phone; | ||
import seedu.addressbook.data.person.ReadOnlyPerson; | ||
import seedu.addressbook.data.tag.Tag; | ||
import seedu.addressbook.data.tag.UniqueTagList; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove extra space? |
||
/** | ||
* Class to generate typical test persons | ||
*/ | ||
public class TypicalPersons { | ||
|
||
public Person amy, bill, candy; | ||
|
||
public TypicalPersons() { | ||
try { | ||
amy = new Person(new Name("Amy Buck"), new Phone("91119111", false), new Email("[email protected]", false), | ||
new Address("1 Clementi Road", false), new UniqueTagList()); | ||
bill = new Person(new Name("Bill Clint"), new Phone("92229222", false), new Email("[email protected]", false), | ||
new Address("2 Clementi Road", false), new UniqueTagList()); | ||
candy = new Person(new Name("Candy Destiny"), new Phone("93339333", false), | ||
new Email("[email protected]", false), new Address("3 Clementi Road", false), new UniqueTagList()); | ||
} catch (IllegalValueException e) { | ||
e.printStackTrace(); | ||
assert false : "not possible"; | ||
} | ||
} | ||
|
||
private void loadAddressBookWithSampleData(AddressBook ab) { | ||
try { | ||
for (Person p : this.getTypicalPersons()) { | ||
ab.addPerson(new Person(p)); | ||
} | ||
} catch (IllegalValueException e) { | ||
assert false : "not possible"; | ||
} | ||
} | ||
|
||
public Person[] getTypicalPersons() { | ||
return new Person[]{amy, bill, candy}; | ||
} | ||
|
||
public AddressBook getTypicalAddressBook() { | ||
AddressBook ab = new AddressBook(); | ||
loadAddressBookWithSampleData(ab); | ||
return ab; | ||
} | ||
|
||
} | ||
public Person amy, bill, candy, dan; | ||
|
||
public TypicalPersons() { | ||
try { | ||
amy = new Person(new Name("Amy Buck"), new Phone("91119111", false), new Email("[email protected]", false), | ||
new Address("1 Clementi Road", false), new UniqueTagList()); | ||
bill = new Person(new Name("Bill Clint"), new Phone("92229222", false), new Email("[email protected]", false), | ||
new Address("2 Clementi Road", true), new UniqueTagList()); | ||
candy = new Person(new Name("Candy Destiny"), new Phone("93339333", true), | ||
new Email("[email protected]", false), new Address("3 Clementi Road", true), new UniqueTagList()); | ||
dan = new Person(new Name("Dan Smith"), new Phone("1234556", true), new Email("[email protected]", true), | ||
new Address("NUS", true), new UniqueTagList(new Tag("Test"))); | ||
} catch (IllegalValueException e) { | ||
e.printStackTrace(); | ||
assert false : "not possible"; | ||
} | ||
} | ||
|
||
private void loadAddressBookWithSampleData(AddressBook ab) { | ||
try { | ||
for (Person p : this.getTypicalPersons()) { | ||
ab.addPerson(new Person(p)); | ||
} | ||
} catch (IllegalValueException e) { | ||
assert false : "not possible"; | ||
} | ||
} | ||
|
||
public Person[] getTypicalPersons() { | ||
return new Person[]{amy, bill, candy, dan}; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Leave at least one blank line between the last method and the closing brace of the class. |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure why this is shown as a diff. Most of it looks identical. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh, this is because there is an extra whitespace for each line, sorry |
||
public AddressBook getTypicalAddressBook() { | ||
AddressBook ab = new AddressBook(); | ||
loadAddressBookWithSampleData(ab); | ||
return ab; | ||
} | ||
|
||
public List<ReadOnlyPerson> getListWithAllPersons() { | ||
List<ReadOnlyPerson> list = new ArrayList<ReadOnlyPerson>(); | ||
for (Person p : getTypicalPersons()) { | ||
list.add(new Person(p)); | ||
} | ||
return list; | ||
} | ||
|
||
public List<ReadOnlyPerson> getListWithSomePersons() { | ||
List<ReadOnlyPerson> list = getListWithAllPersons(); | ||
list.remove(0); //remove a person in the list | ||
return list; | ||
} | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a line feed at the end of the file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be initialized at the same place it's declared. Junit creates a new instance for each test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@damithc This
TestUtil.createAddressBook()
is throwing an excpetion inTestUtil
Class so cannot put outside right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case can keep.