locked
Moles, NUnit and Test/Fixture Setup methods RRS feed

  • Question

  • How do i get a Moled class to work inside of an NUnit Test/Fixture Setup method.  Currently, the setup method is called, but not from within a moled context.  Hence not able to setup tests/fixtures with moled classes for stuff that would be pretty much common across all test methods.
    Friday, December 31, 2010 5:19 AM

Answers

  • The problem is that the MolesContext resets all moles when it gets disposed. Thus, if you use a MolesContext in your setup method, its effects will be reseted by the time you execute the test.

    You will need to hardcode the calls to 'Setup/Teardown'. 


    Jonathan "Peli" de Halleux - Try Pex online at www.pexforfun.com!
    Wednesday, January 5, 2011 3:59 AM

All replies

  • Unfortunately, Setup/Teardown methods are not supported with Moles (in any frameworks).
    Jonathan "Peli" de Halleux - Try Pex online at www.pexforfun.com!
    Wednesday, January 5, 2011 3:57 AM
  • The problem is that the MolesContext resets all moles when it gets disposed. Thus, if you use a MolesContext in your setup method, its effects will be reseted by the time you execute the test.

    You will need to hardcode the calls to 'Setup/Teardown'. 


    Jonathan "Peli" de Halleux - Try Pex online at www.pexforfun.com!
    Wednesday, January 5, 2011 3:59 AM
  • That's exactly what i have done for now.  Was wondering if there would be a better way.

    Would be nice to have a declarative way of getting this done.

    Wednesday, January 5, 2011 4:23 PM