• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is the best practice?

 
Marcin Mogiela
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lets assume we have the following:



Test cases:



What would be the best solution to test h() method?

* one solution that comes to my mind is:


* 2nd solution:


* 3rd:

[ March 20, 2008: Message edited by: Marcin Mogiela ]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33671
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Marcin,
This is mainly a personal preference, but I like #1 the best. Ideally, I would see if I could make f() and g() private and test entirely through h().
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Jeanne, unless f() and g() are very complex and/or slow. (In general, these things are much easier to discuss on real examples.)
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33671
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ilja Preuss:
unless f() and g() are very complex and/or slow.

And I agree with Ilja

I assumed f() and g() were ok to unit test since the original post included a unit test for them.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic