aspose file tools*
The moose likes Java in General and the fly likes ArrayList in a tester class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "ArrayList in a tester class" Watch "ArrayList in a tester class" New topic
Author

ArrayList in a tester class

Lisa Beglaw
Ranch Hand

Joined: Jul 16, 2005
Posts: 65
I am building a tester class and one of my methods I need to test is...


I am not sure how I can build this in my tester class.
I took a shot in the dark and tried...

...but no luck.

Any suggestions?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41870
    
  63
What constitutes a test? A meaningful test has a pre-condition, some kind of action, and a post-condition. What are those in your situation?

Since you don't seem to be using the result returned by "movieCollection.neverBeenRented()", how/what would it be testing?


Ping & DNS - my free Android networking tools app
Lisa Beglaw
Ranch Hand

Joined: Jul 16, 2005
Posts: 65
I guess what I am testing is that when I test the method neverBeenRented() it creates the ArrayList and moves my two never been rented movies into it.

edited for spelling.
[ August 10, 2005: Message edited by: Lisa Beglaw ]
Lisa Beglaw
Ranch Hand

Joined: Jul 16, 2005
Posts: 65
I just finished and have every other test method working in my test class except the Array.

I can see it doesn't follow the same pattern as the rest do with testing, but I am not sure what I am missing.
Saeed Amer
Ranch Hand

Joined: Jan 20, 2004
Posts: 140
Could you please post your code and let us know what exactly is missing?
Lisa Beglaw
Ranch Hand

Joined: Jul 16, 2005
Posts: 65
What I twit I am...here it is...

And the method I am trying to test is
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41870
    
  63

I guess what I am testing is that when I test the method neverBeenRented() it creates the ArrayList and moves my two never been rented movies into it.


In that case, wouldn't



do the trick? Or are you using JUnit?
Lisa Beglaw
Ranch Hand

Joined: Jul 16, 2005
Posts: 65
If statements in a tester class? Have you opened up a whole new world to me?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41870
    
  63

Have you opened up a whole new world to me?


If so, then it was easy. Hope I can do it again some time

Maybe we don't have the same concept of a "tester class". My idea would have been that it's either a general class whose purpose is to test some other class (in which case it may do so by whatever means available), or maybe a JUnit test, in which case the above would be something like "assertEquals(2, movieCollection.neverBeenRented().size())". Are you working with another definition?
[ August 10, 2005: Message edited by: Ulf Dittmer ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ArrayList in a tester class