130 likes | 258 Vues
Join Aaron Powell as he delves into the essential concepts of unit testing in the context of Umbraco development. Discover the importance of separating logic from UI to create reusable components, and learn how to reduce errors with repeatable tests in controlled environments. Explore advanced topics like stubs, mocks, and whether to use a mocking framework. Gain insights into using Dependency Injection and the Factory Pattern for better API design. Don't miss this opportunity to elevate your coding skills and enhance your development practice!
E N D
Unit Testing • Secrets of an Umbraco Ninja • Presented by: • Aaron Powell me@aaron-powell.com @slace www.aaron-powell.com
What and Why? • Not Test Driven Development • Separation of logic from UI • Ability to create reusable components • Reduced errors by repeatable tests in controlled environments • Better API design
Stub & Mocks • Stub is an instance which wont break your test • Stubs can be implementations of a class created purely for testing purposes • Mocks • Less common in current unit testing • Type instances where nothing is defined • Can be very brittle
Frameworks • Do you need a mocking framework? • Short answer is no • Can create your own stub types • Gives you greater control • Why to use one? • Easy expectation setup • Using stubs on less accessible types • Set-less properties
Development • WebForms MVP to abstract away ASP.NET WebForms features • Dependency Injection to simplify the creation of factory types • Factory Pattern for data access
With Umbraco • Heavy reliance of HttpContext • Hard to Mock • Requires a web context • Lots of static • Hard to mock • Changing data • What are we working against?
Questions? Thank you for coming