Detroit.Code() Sessions tagged unit testing

Awesome C#: Unit Testing

Unit testing can make you a faster developer. Good tests let us move forward more confidently, give us instant feedback when checking regression, and help us pinpoint bugs when things go wrong. In this workshop, we'll look at the qualities of good tests, including isolation, repeatability, runnability, and more. And we'll look at specific techniques that make our tests easy to ready, easy to write, and easy to run.

We'll go hands-on with TDD (Test-Driven Development) to see the red-green-refactor cycle in action. Some code is tricky to test: we'll look at how to test for exceptions and error states, and we'll use a mocking framework to create mocks and stubs. Tools include MSTest and NUnit (for testing) and MOQ (for mocking), but the skills easily translate to other frameworks.

Objectives 1. Why Unit Test? Getting the actual benefits 2. Characteristics of a good unit test and how to implement them (including isolation, repeatability, runnability, and more) 3. Basics of TDD 4. Parameterizing tests 5. Techniques for testing exceptions 6. Using a mocking framework to isolate dependencies

Pre-Requisites Basic understanding of C# and object-oriented programming (classes, inheritance, methods, and properties). In addition, experience with interfaces and other forms of abstraction is very helpful. No prior experience with unit testing is necessary; we'll take care of that as we go.

Speaker

Jeremy Clark

Jeremy Clark

Developer Betterer, JeremyBytes.com

Unit Testing Strategies & Patterns in C#

Learn common patterns and strategies to effectively unit test your code in C#. We’ll go over design principles and ways to effectively ensure your code can be easily tested as well as how to use common testing tools such as Moq, Autofixture, & MsTest to help remove some of the drudgery of testing.

Testable code is a widely advocated industry standard but the barrier to entry is incredibly high. In this talk, we’ll go over not just how to unit test your code using MsTest, Moq, & AutoFixture but the patterns & processes to ensure your code can be unit tested. We will touch on the basics of dependency injection and common patterns such as avoiding the use of static classes but also more advanced topics such as SOLID design principles and how they relate to testing.

We’ll give the attendees a wide variety of examples on how to test common C# projects such as web api and console applications and different scenarios such as how to test databases and external method calls. Many real world tips & tricks on dealing with common patterns and scenarios will be included to make your life easier. Most importantly, attendees will be given a good idea of how to start testing, how to measure the effectiveness of their tests, and what not to test.

Speaker

Bill Dinger

Bill Dinger

Solutions Architect, VML