XpdWiki
Set your name in
UserPreferences Edit this page Referenced by
JSPWiki v2.0.52
![]() ![]() |
Say I test class A which depends on class B (i.e. it calls methods of B). How do I test class A apart from B. Solution: Extract B's interface in IB and provide an implementation of IB with MockB?. MockB? can verify if appriopriate methods are called. To do that, MockB? is part of the test framework. Abstract classes have a similar problem. They often implement some mechanisms and use template methods to call subclass functionality. So say i have an abstract class AA which calls method M, i would like to have a MockObject MockSA? which verifies that method M is called. Problem: i can't derive MockSA? from A. How do you cope with this guy's? -- RobWestgeest Maybe my real problem is MockType?. Why is it derived from TestCase? Why isn't it an Interface? -- RobWestgeest Which version of the library do you have? Currently, we tend to have mock objects implement Verifiable, which is an interface. We're also going to supply a MockObject class, but largely as a convenience. I imported the bigben107.dat in VA and used the XPdeveloper Testing 2.33 project. Are there newer versions? -- RobWestgeest As for testing abstract classes, we find that we tend to end up with a test class hierarchy that mirrors the target class hierarchy. This often gives us an abstract test class that mirrors the abstract target class and which is extended by the appropriate test class. That said, we don't usually set out to achieve this structure, we get there by refactoring. If you look in the test cases for the expectation library, you'll see something similar for testing the expectation collections. --SteveF If you suggest that there is an ExpectationCollection? hierarchie (i.e. ExpectationList? and ExpectationSet? derived from an ExpectationCollection? base class) and a Verifiable interface I most definitely have the wrong version. Is there an update? --RobWestgeest Try http://www.mockobjects.com ³³agent³Mozilla/4.0 (compatible; MSIE 5.0; Windows NT 5.0) Opera 5.02 en?³TestingAbstractClasses
|