Test Driven Development and Refactoring in C#, C++
Test-driven development makes software quality part of the development process and at the same time creates a safety net for future changes to your product. Starting from the basics of unit testing, this workshop guides the participants through specific code examples and exercises to show them how to do TDD efficiently and in a sustainable manner, getting the most out of this methodology while avoiding its pitfalls.
The course is available in the following programming languages: C#, partly in C++.
Software developers with minimum 3 years C# background or years of practice in other programing languages.
The material is divided into 4 modules. During each module, the trainer will guide you through lectures and exercises that help you connect the material to your existing experience, learn new concepts and experience the concepts through practice.
The course also points of when TDD is not the appropriate tool, to build a balanced view about TDD.
During the course students have the opportunity to learn many useful open source and commercial tools for efficiently practicing TDD, like NCrunch, Resharper, Fluent Assertions, NSubstitute, NBuilder, etc
Introduction to Unit Testing
This module introduce unit testing, contrast it to integration testing, and shows how to write tests in MSTest (or NUnit).
Key topics during this module: Tradeoff of unit tests, Cyclomatic Complexity, Unit test vs. Integration Test, problems with Integration Tests, Effect of modifications for different type of tests. Introduction to TDD. Visual Studio test framework, Visual Studio test features like debugging, coverage and profiling. Test Attributes, Test generation, Assert types and methods, TestContext, Data Driven Tests. Setting test environment using testSettings and runSettings files. Deployment issues. Coverage measuring and visualisation. Using NCrunch to run tests automatically. Using Visual Studio automatic test runner and Live Testing. Fluent Assertions, Intelli Test, Async testing.
Unit Testing Theory
What to test, why to test, how to test? Test principles by Right BICEP and CORRECT. Test antipatterns.
Key topics during this module: Arrange-Act-Assert, Boundary tests, Inverse Relationships, Cross-checking, Forced Error Conditions, Performance Characteristics, Conformance, Cardinality, Ordering, Range, Reference checks, Existence, Cardinality, Time dependent tests. 11 Test antipatterns.
Using Fakes to isolate dependencies
Writing true unit test by isolation, decoupling dependent objects to test 1 thing only.
Key topics during this module: State and Interaction tests, Fakes, Stubs, Mocks, Dependency Injection, AutoFac, Creating seams, Extract and Override, Refactoring tightly coupled code to a testable one. Generating fakes using Isolation Frameworks, NSubstitute, Visual Studio Fakes.
Theory of refactoring from Fowler’s Refactoring book, practices using Resharper to refactor real-word examples of bad design and code smells. In addition to this we introduce .NET specific refactoring as well.
Key topics during this module: Rename Method, Extract Method, Replace Temp with Query, Inline Method, Inline Temp, Hide Method, Move Method, Move Field, Introduce Explaining Variable, Introduce Field, Add Parameter, Introduce Parameter Object, Remove Parameter, Safe Delete, Remove Unused Assembly References, Change Signature, Extract Class, Replace Method with Method Object, Introduce Foreign Method, Replace Magic Number with Symbolic Constant, Replace Nested Conditional with Guard Clauses, Remove Assignments to Parameters, Encapsulate Field, Auto Property to Backing Field, Remove Setting Method, Replace Constructor With Factory Method, Decompose Conditional, Replace Exception with Test, Replace Error Code with Exception, Encapsulate Collection, Extract Interface, Extract Superclass, Pull Up Field, Pull Up Method, Pull Up Constructor Body, Push Down Method, Push Down Field, Form Template Method, Encapsulate Downcast, Duplicate Observed Data, Replace Data Value with Object, Replace Type Code with Class, Replace Type Code with Subclasses, Replace Type Code with State/Strategy, Parallel Collections, Convert foreach to LINQ, Convert for to foreach. Code smells and solutions to them.
Test Driven Development
Theory of TDD according to Kent Back. How to approach TDD, what are the main guidelines to choose the next test? This is the last day of the course, and most of the day we collectively build an application using TDD.
Key topics during this module: Test Driven Development Patterns, Test List, Assert First, Test data considerations, Starter test, One step test, Learning test, Regression test, Fake it till make it, Triangulation.
- Duration: 4 Days.
- Classroom with computers is required
- Hungarian handout and the source code of the demo applications will be provided for the participants.
- 2 whiteboards and a beamer with HDMI is required.
- No exam associated with this course