This week's book giveaway is in the Agile forum.
We're giving away four copies of Head First Agile and have Andrew Stellman & Jennifer Greene on-line!
See this thread for details.
Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Test program?  RSS feed

 
Lm Taylor
Greenhorn
Posts: 3
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having some trouble writing a test program for an assignment in school. The assignment was for an Account.class with two subclasses, Checking.class and Savings.class, and finally, one TestAccount.class. My question is, how do I create one test class to include the two subclasses? Wouldn't the Test have to extend both Checking and Savings in order to test them completely, but in Java you can only inherit from one class, right?

Thanks for your help.
 
Paul Clapham
Sheriff
Posts: 22531
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't believe that the testing class has to be a subclass of the class it's testing. In fact I don't see how that would be useful. Did your teacher tell you to do that?
 
Lm Taylor
Greenhorn
Posts: 3
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The instructor just said to include testing to verify withdrawal amounts are within preset limits for both checking and savings. I assumed the test would need to be a subclass in order to test the withdrawal methods for checking and savings. If not, how should I create the test?
 
Henry Wong
author
Sheriff
Posts: 23284
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lm Taylor wrote:The instructor just said to include testing to verify withdrawal amounts are within preset limits for both checking and savings. I assumed the test would need to be a subclass in order to test the withdrawal methods for checking and savings. If not, how should I create the test?


Most test classes simply instantiate objects and use them... so, instantiate a savings and a checking object, and test the methods. No need to subclass to use objects / classes.

Henry
 
Lm Taylor
Greenhorn
Posts: 3
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, I get it. For some reason, I thought you couldn't use a class or its methods unless it was a super/sub class.
Thank goodness for newbie forums.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!