Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Test program?

 
Greenhorn
Posts: 3
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 27379
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
author
Posts: 23928
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I think he's gonna try to grab my monkey. Do we have a monkey outfit for this tiny ad?
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic