This is a migrated thread and some comments may be shown as answers.

Let test fail if an external (not mocked) method is called

1 Answer 26 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Christian
Top achievements
Rank 1
Christian asked on 20 May 2014, 12:12 PM
Is it possible to let tests fail or throw an exception if a test calls a method that is not mocked?
exmaple:
method A calls method B and C
B is mocked and C is not mocked, but produces a valid result -> the test is ok, but it is not a valid unit-test.
I need a way to force the developer to write valid unit-tests. That means: as soon as a method calls an "unmocked" method the test should fail or generate an exception.
Is there an easy way to do this?

thx

1 Answer, 1 is accepted

Sort by
0
Kaloyan
Telerik team
answered on 23 May 2014, 07:59 AM
Hello Christian,

This is completely achievable by applying a strict behavior to your mocks. With it, the execution of any un-arranged method from that mock, will throw an exception. More details about this can be found here. You can also check the samples in our JustMock example projects.

I hope this helps.

Regards,
Kaloyan
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
General Discussions
Asked by
Christian
Top achievements
Rank 1
Answers by
Kaloyan
Telerik team
Share this question
or