120 likes | 225 Vues
The Moles Isolation Framework is designed to enhance Test-Driven Development (TDD) processes by allowing the replacement of .NET methods with delegates, facilitating better unit testing in complex environments. This framework supports the mocking of external dependencies and enables the initialization of object properties through well-defined known states. While it offers advantages such as simulating various data types and abstracting system resources, it also poses challenges like increased assembly size and debugging difficulties. Learn about its capabilities, limitations, and best practices in this comprehensive overview.
E N D
TDD Process Code
TDD Process Code
Stareacunoscuta (Known State) • Se poaterealizaprin: • Initializarea/setareaproprietatilorobiectuluitestat • Emulareadependintelorexterne (mocking)
Stareacunoscuta (Known State) • Se poaterealizaprin: • Initializarea/setareaproprietatilorobiectuluitestat • Emulareadependintelorexterne • Mock objects
Stareacunoscuta (Known State) • Se poaterealizaprin: • Initializarea/setareaproprietatilorobiectuluitestat • Emulareadependintelorexterne • Mock objects • Manual • Mock framework (Rhino Mocks, Moq, TypeMock etc.)
Mock objects • Pot “simula” doarce pot inlocui (override): • Interfete • Clase/metodeabstracte • Metodevirtuale • Nu pot “simula”: • Clase/metodestatice • Metode non-virtuale, sealed • Clase sealed • Clase care nu au fostproiectatepentrutestare • Value types
Moles Isolation Framework • Conceput initial ca parte a PEX • Permiteinlocuireaoricareimetode .NET cu un delegate • Suporta: • Metodestatice • Metode non-virtuale • Value types (de ex. DateTime)
Avantaje/dezavantaje • Avantaje • Se poatesimula (mock) orice tip de date, oricemetodasioriceproprietate • Permiteimplementarea de unit tests in locul integration tests • Permiteabstractizarearesurselorsistem • Dezavantaje • Timpridicat de initializare • Crestemultdimensiunea assembly-ului de test • Daca se intrerupe debugging-ul, procesul host varamanepornit • Schema de naming explicitapoate duce la situatiidificil de citit MDateTime.TryCreateInt32Int32Int32Int32Int32Int32Int32DateTimeOut
Resurse • Moles: http://research.microsoft.com/en-us/projects/moles/ • Proiect & prezentare: • www.byteflux.me