This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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
Rancher

Joined: Mar 22, 2005
Posts: 42958
    
  73
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?
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
Rancher

Joined: Mar 22, 2005
Posts: 42958
    
  73

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
Rancher

Joined: Mar 22, 2005
Posts: 42958
    
  73

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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: ArrayList in a tester class
 
It's not a secret anymore!