Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tools for testing static methods

 
Dale DeMott
Ranch Hand
Posts: 515
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know of any testing tools that will Unit test static methods?
 
John Lee
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
extrem programming
 
John Lee
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mock object
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's a mock object, Don? I've heard of a Mock Turtle, but mock object never. Could you explain in full detail?
Thanks
-Barry
 
John Lee
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mock object
it is pretty new to me. if this is not good enough, just do s search on google.
 
Don Kiddick
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JUnit
 
John Lee
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mock Objects is perhaps the best resource on the net.
 
Dale DeMott
Ranch Hand
Posts: 515
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
John Lee
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Dale DeMott
Ranch Hand
Posts: 515
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Usually with mock objects you create an interface that has the same method calls as your original object that you are testing. Then you have both your mock object and your original object implement the same interface. Then you have your program use this interface instead of your real object. This allows you to switch out the real object and the mock object without your program knowing objects have been switched out.
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 ]
 
John Lee
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well, i just start reading on mock object, but i am sure you will fiind better answer in test forum.
 
Dale DeMott
Ranch Hand
Posts: 515
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For MockObjects, I have already looked for a solution. I was wondering if someone found something other than MockObjects that can help you with this. (And yes. Cindy should move this to the Testing forum)
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just what I was thinking. Moving to the Testing Forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic