1 / 12

Moles Isolation Framework

Moles Isolation Framework. TDD Process. TDD Process. Code. TDD Process. Code. The Known State. Can be accomplished by: Initializing or setting the properties and fields of the tested object Emulating external dependencies (mocking or stubbing). The Known State. Can be accomplished by:

horace
Download Presentation

Moles Isolation Framework

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Moles Isolation Framework

  2. TDD Process

  3. TDD Process Code

  4. TDD Process Code

  5. The Known State • Can be accomplished by: • Initializing or setting the properties and fields of the tested object • Emulating external dependencies (mocking or stubbing)

  6. The Known State • Can be accomplished by: • Initializing or setting the properties and fields of the tested object • Emulating external dependencies (mocking or stubbing): • Mock objects

  7. The Known State • Can be accomplished by: • Initializing or setting the properties and fields of the tested object • Emulating external dependencies (mocking or stubbing): • Mock objects • Manually created classes • Mock framework (Rhino Mocks, Moq, TypeMock etc.)

  8. Mock objects • They can stub only what they can override: • Interfaces • Abstract classes and/or methods • Virtual methods • They cannot stub: • Static methods or classes • Non virtual or sealed methods • Sealed classes • Classes that have not been designed for testing/mocking • Value types

  9. Moles

  10. Moles Isolation Framework • Initially a part of the PEX • Allows the replacing of any .NET method or property with a delegate • It supports: • Static methods • Non virtual methods • Value types (DateTime etc.)

  11. Pros/cons • Pros • Any data type, method or property can be mocked • Allows creating unit tests where only integration tests would have been possible • Allows abstracting the system resources • Cons • High initialization time • Test assembly size can grow very quick • Stopping the test while debugging it will leave the host process running and will require to be terminated manually • Naming scheme can become very cumbersome and hard to read: MDateTime.TryCreateInt32Int32Int32Int32Int32Int32Int32DateTimeOut

  12. Resources • Moles: http://research.microsoft.com/en-us/projects/moles/ • Presentation and demo project: • www.byteflux.me

More Related