Indy.Code() Sessions tagged moq

Writing For The Test : Dependency Injection Coding Practices for Effortless Unit Testing

Wherever there is code, there will be bugs. Catching these bugs before they reach production is key to creating happy users, building trust in your organization, and enhancing your own reputation as a skilled developer. Unit testing can be a powerful tool in an organization's arsenal when fighting for bug-free code. A good unit test is easy to write, and can catch a bug in an instant, without even running your application. But there is a catch: before you can write a powerful, bug-fighting unit test, your code must be testable. In this session, you will learn how to design and implement code that is unit test-ready. We will explain the Dependency Injection Principle and how to implement it, Inversion of Control Containers and when to use them, the power of Mock objects, and clean code practices as they apply to unit test readiness.

Speaker

Laura Northrup Poland

Laura Northrup Poland

Senior Software Engineer, PFL

Unit-Testing With Ease

Do you want to skip all the setup ceremony and get straight to the actual testing when writing unit tests? Leveraging dependency injection and IoC makes it a breeze to build solutions that are modular and testable, but building out those dependency chains in our unit tests can leave them cluttered and overly complex. It's time to learn to embrace the magic of IoC, DI, and mocking to lower the friction of writing and maintaining unit tests. Taking cues from the open-source library Ease, you can see how to tap into the life-cycle of unit testing frameworks and integrate it with an IoC container to give you a fresh start for each test. Throw in a little mocking and a flexible pattern for managing setup and now you are testing in high gear! A great side-effect of using Ease, or a similar methodology, is that tests become more resilient against changes in the dependencies that are not a direct concern of the test, so you end up breaking fewer tests and changing less test code. What are you waiting for? Stop the ceremony, and start testing!

Speaker

Duane Newman

Duane Newman

Co-Founder, Alien Arc Technologies, LLC