Unit test smell

I am trying to modify unit testing of ArcGIS and start using mocks (I use rhino).
When I started writing tests, I noticed that I should start taunting a lot of objects and stopping a lot of methods even for passing one test.
For example, my controller first receives RelationshipClass(so I need to stub IWorkspaceand returned IRelationshipClass), then it also receives IFeature(A stub) and finally calls stubRelClass.GetRelatedObjects(stubFeature)to return a ISetothers IFeatures.

Is it normal to have so many objects and methods that they go through? I also feel, for example, that I really need to step over the code (yes, I know that I had to write tests first, I'm still trying to do this) to find out what to do next and what I should return.

I also have a problem with mocking com classes that implement more than one interface. In the production code, I QI them between the interfaces. How can I create a layout that implements both interfaces at runtime?

+5
source share
3 answers

, , . , , - , , API, . , - - , , , .

[SetUp], .

Rhino MultiMock. , , , :

var mock = 
    MockRepository.DynamicMultiMock<MyType>(
              typeof(Interface1), 
              typeof(Interface2), 
              ....);
+3

, , , ( ). 4-6 . , , .

Mocks?

+3

, :-(

http://misko.hevery.com/code-reviewers-guide/. , Google . , .

Further Recommended Reading: Clean Code (Robert C. Martin) - The focus is on how to write clean (which matches the code being checked) code. Effective work with outdated code (Michael Feather) - shows how to get unverified and unverified code under control.

+2
source

All Articles