unit testing a method that returns a non trivial object -
How to test a method that returns a complex object that does not allow access to its fields on this snippet Consider -
Get public results getResultState () {ResultState resultState = new ResultState (); // logic // it RestelState = ResultState; // set parent parent class field results; }
ResultState is an object which does not allow its many methods and areas.
assertNotNull (object.getResultState ()) / / Return ResultState is used by other class methods
My question is normal, but I hope That it shows how to get a hint about how to go on trial ... Thanks for the help
OK, what's important about the result? Perhaps it can do something or it would be a worthless result, in this case, the code that works with broken codes will be separated?
(I am not trying to make light of the problem - sometimes it is very difficult to keep tight encapsulation but test effectively. To make an object a bit easier, test ...)
Comments
Post a Comment