Okay, here's what happening. I am attempting to set up test code for a Library class that I set up. Now, I'm supposed to adjust my constructor to automatically create an entry in my array list before a new one is added. Here's my constructor:
public DvrLibrary()
{
recordings = new ArrayList < DvrRecording > ();
DvrRecording initialRecording = new DvrRecording();
initialRecording.setTitle("Family Guy");
initialRecording.setStartTime("10:00pm");
for (int i = 0; i < 3; ++i) { initialRecording.increaseTime(); }
recordings.add(initialRecording);
}
When I created my test case, I have the test code as:
public void testARecording()
{
DvrLibrary testLibrary = new DvrLibrary();
ArrayList < DvrRecording > testList = new ArrayList < DvrRecording > ();
DvrRecording testRecording = new DvrRecording();
testRecording.setTitle("Lost");
testRecording.setStartTime("Later");
for (int i = 0; i < 3; ++i) { testRecording.increaseTime(); }
testLibrary.addRecording(testRecording);
testList.add(testRecording);
assertEquals(testLibrary.getRecordings(), testList);
}
My problem is, when I run the actual test, the default, I'm pretty sure, is not being called. It is returning a failed error message telling me that it was expecting to find two entries but only found one. I tried cutting out the new entry that the test code is creating and the error read that there was supposed to be one, but found nothing.
This leads me to believe that there is something wrong with the way I set up the constructor in the actual code, but I cannot for the life of me figure out what I messed up. When I went to get help, the guy I talked to was like welllll I'm not sure what's wrong but you could be messing up the assert. But I don't know what's wrong?
Anyone have any input? I'd really appreciate it. Thanks!