1 / 10

Testeando lo intesteable con el framework de Moles

Testeando lo intesteable con el framework de Moles. Luis Ruiz Pavón http:// luisruizpavon.com http:// twitter.com/luisruizpavon. Agenda. Qué es el framework de Moles Diferencia entre Stubs y Mocks Diferencia entre Moles y Stubs Demo Stubs (Moles) y Mocks ( Moq )

hansel
Télécharger la présentation

Testeando lo intesteable con el framework de Moles

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. Testeando lo intesteable con el framework de Moles Luis Ruiz Pavón http://luisruizpavon.com http://twitter.com/luisruizpavon

  2. Agenda • Qué es el framework de Moles • Diferencia entre Stubs y Mocks • Diferencia entre Moles y Stubs • Demo Stubs (Moles) y Mocks (Moq) • Demo testing ASP.NET • Demo testing librería de terceros • Demo testing SharePoint

  3. Qué es el framework de Moles • Es un framework de Stubs, pero además nos permite testear clases selladas, clases con constructores privados, métodos estáticos, no virtuales… mediante el uso delegados (o lambdas).

  4. Qué es el framework de Moles • Delegate fs.ReadAllTextString= delegate(string f) { Assert.IsTrue(f == fileName); return content; }; • Lambda fs.ReadAllTextString= (f) => { Assert.IsTrue(f == fileName); return content; };

  5. Diferencia entre Stubs y Mocks • Stubs sirven para simular funcionalidad. • Mocks sirven para comprobar interacción a través de caracterísiticas de verificación. • Para hacer mocking hace falta hacer stubbing

  6. Diferencia entre Moles y Stubs • Stubs: Para testear clases que implementan interfaces o clases no selladas con métodosque se puedensobreescribir(Esto podría hacerse con otros frameworks de mock tales como Moq, RinhoMocks…) • Moles: Para testear clases selladas y con métodos estáticos o que no se pueden sobrescribir (Clases que tenga fuertes dependencias).

  7. Diferencia entre Moles y Stubs • Stubs: Empieza por el prefijo S. Para un tipo T tendremos una implementación de cada método virtual o abstracto, propiedades y eventos. • Moles: Empiezan por el prefijo M y para un tipo T tendremos una implementación para cada miembro no abstracto.

  8. Cuando usar Moles ó Stubs • Usaremos stubs paraaislardependenciashaciendousos de interfaces. • Usaremos moles cuandonecesitemostestear frameworks o código de tercerosque no suministran un API testeable.

  9. DEMOs

  10. Referencias • Microsoft ResearchPex & Moles • http://research.microsoft.com/en-us/projects/pex/ • Descargas • http://research.microsoft.com/en-us/projects/pex/downloads.aspx • Geeks • http://geeks.ms/search/SearchResults.aspx?q=moles

More Related