提出问题提出问题
 

已答复What Mocking Framework to use?

  • 2009年6月17日 9:39Dynamic 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     

    I am using MSTest to write my unit tests. I am just wondering what mocking framework do you recommend me to use? or you have a good experience with it.

    Mocking frameworks I have seen:

    • TypeMock (although it's good but it's not free and my Company is not willing to pay for it)
    • NMock (doesn't let me mock static methods apparently)
    • EasyMock
    • RhinoMock (doesn't let me mock static methods apparently)
    • Moq

    I need to be able to mock static classes and static methods (for instance mocking HttpContext)

    Thanks.

     


答案

全部回复

  • 2009年6月17日 13:49p.b.a 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     已答复
    No mocking framework based on transparent proxies will let you mock static classes /methods so you're left only with TypeMock (the rest of them are using AFAIK transparent proxies).

    HTH
    Paul
  • 2009年6月17日 14:29Dynamic 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    Thanks Paul for your response.

    I imagine I need to write some helper classes for mocking static methods that I require.

    I found this which contains some helper classes for Rhino Mocks and Moq.