發問發問
 

已答覆What Mocking Framework to use?

  • 2009年6月17日 上午 09: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日 下午 01: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日 下午 01: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日 下午 02: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.