Presentation is loading. Please wait.

Presentation is loading. Please wait.

Test Driven Development

Similar presentations


Presentation on theme: "Test Driven Development"— Presentation transcript:

1 Test Driven Development
TDD Test Driven Development

2 Different Approaches To Testing
White box Testing Unit Testing Block box Testing Beta Testing Regression Testing Acceptance Testing Usability Testing Integration Testing Functional Testing System Testing Stress Testing Performance Testing

3 Unit Test Unit testing is a software development process in which the smallest testable parts of an application, called units, are individually and independently scrutinized for proper operation. Unit testing can be done manually but is often automated.

4 Test Driven Development
Process that uses unit tests to drive the design of software.

5 Different Kinds of Testing Tools
MSTest – Official unit tester created by Microsoft xUnit – Open source unit tester developed for .NET NUnit – Open source unit testing framework inspired by Java’s Junit

6 The mantra of TDD is RGR

7 Test First vs Test Last

8 Robert C.Martin’s Laws No production code until you’ve written a failing test. Write no more in your unit test then enough to make it fail. Write no more production code than enough to make it pass.

9 Mocking Frameworks FackItEasy – Mocking framework where objects are considered fakes but usage determines whether they are mocks or stubs. NSubstitute – Mocking framework syntax that is more succinct and concise. Moq – Mocking library developed from scratch to take full advantage of .NET.

10 Creating your first Unit Test
Remember the Three-A’s pattern A pattern for arranging and formatting code in Unit Test methods

11 Asserting the facts

12 Assembly Initialize

13 Class Initialize and Class cleanup

14 Test Initial and Test Cleanup

15 Debugging Unit Test Unit tests can be debugged just like any other code. Break points can be set anywhere in your code To pause at breakpoints you have to explicitly run tests in debug mode.

16 MSTest.exe Used for execution of unit tests from command line
Located under “\common7\IDE” Command line options: Command Line Option Description /testcontainer: [file name] All test in the assembly (container) /test: [test name] A single test /testlist: [test list path] A test list /testsettings A specify a test settings file

17 Run unit tests with your builds
Run tests after every build on VS(Local): Running unit tests after every build is supported in Visual Studio Enterprise. To run your unit tests after each local build, choose Test on the standard menu, and then choose Run Tests After Build on the Test Explorer toolbar. Run tests after every build on TFS(Server): Running unit tests after every build is supported in TFS. To run your unit tests after each build, register Build Definitions with agent on the build menu from TFS and run Queue build that you created for Build.

18 Summary TDD DRY YAGNI KISS Test First and Test Last Build with Test
Red – Green – Refactor DRY Don’t repeat yourself YAGNI You aren’t gonna need it KISS Keep it short and simple Test First and Test Last Build with Test 3A Pattern Debugging Unit Test For more details go to


Download ppt "Test Driven Development"

Similar presentations


Ads by Google