Tools for testing static methods
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
By failing to prepare, you are preparing to fail.<br />Benjamin Franklin (1706 - 1790)
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Thanks
-Barry
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
it is pretty new to me. if this is not good enough, just do s search on google.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
By failing to prepare, you are preparing to fail.<br />Benjamin Franklin (1706 - 1790)
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Originally posted by Dale DeMott:
Are you sure Mock Objects will allow you to test static methods? In working w/Mock Objects, it is to my understanding that these objects mock the original objects so you can stub in the method calls. Does this hold for static methods as well?
i can not see static methods make big difference here...but i am not sure.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Car implements ICar
MockCar implements ICar
ICar car = new MockCar();
//The code below wouldn't know if 'car' is a mock or not.
This is usually how mock objects are used. (At least in our shop) This leaves out the ability to test static methods. Does anyone else have another method that might be more elegant?
[ May 08, 2003: Message edited by: Dale DeMott ]
By failing to prepare, you are preparing to fail.<br />Benjamin Franklin (1706 - 1790)
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
By failing to prepare, you are preparing to fail.<br />Benjamin Franklin (1706 - 1790)
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
"JavaRanch, where the deer and the Certified play" - David O'Meara
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I did find a product that can help you with this, however I guess I was looking for something that might be open source or free. I did find a product that can do this... that was AgileTest.
http://www.polygenix.com
Explaining my point a bit farther.. read my example below...
Example-
You are testing MainClassObject
MainClassObject depends on DependantClassA and DependantClassB.
DependantClassA and DependantClassB both have static methods in them. Using MockObjects, how might you test MainClassObject? Or is there any other testing sub-systems that can help you with this? (Besides AgileTest)
-Dale
[ May 08, 2003: Message edited by: Dale DeMott ]
By failing to prepare, you are preparing to fail.<br />Benjamin Franklin (1706 - 1790)
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
What you can do, is not calling the static method directly, but through a Facade object. The production facade can delegate to the static method, and you can mock it in your tests.
Did that help?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
By failing to prepare, you are preparing to fail.<br />Benjamin Franklin (1706 - 1790)
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Original code:
New code:
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Dale
By failing to prepare, you are preparing to fail.<br />Benjamin Franklin (1706 - 1790)
| Die Fledermaus does not fear such a tiny ad: The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |











