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

2 posts, 0 answers
  1. Christian
    Christian avatar
    5 posts
    Member since:
    Apr 2013

    Posted 20 May 2014 Link to this post

    Is it possible to let tests fail or throw an exception if a test calls a method that is not mocked?
    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?

  2. Kaloyan
    Kaloyan avatar
    871 posts

    Posted 23 May 2014 Link to this post

    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.


    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.

  3. DevCraft R3 2016 release webinar banner
Back to Top