Presentation is loading. Please wait.

Presentation is loading. Please wait.

Unit testing in.Net. Copyright 2007 Tikal Knowledge, Ltd. | 2 | Agenda Introduction Visual Studio built-in support Open source frameworks Working together.

Similar presentations


Presentation on theme: "Unit testing in.Net. Copyright 2007 Tikal Knowledge, Ltd. | 2 | Agenda Introduction Visual Studio built-in support Open source frameworks Working together."— Presentation transcript:

1 Unit testing in.Net

2 Copyright 2007 Tikal Knowledge, Ltd. | 2 | Agenda Introduction Visual Studio built-in support Open source frameworks Working together Unit testing in real life Summary

3 Copyright 2007 Tikal Knowledge, Ltd. | 3 | Introduction: importance of unit testing Better software quality Faster development cycles Easier refactoring Finer granularity of commits Easier measurement of progress

4 Copyright 2007 Tikal Knowledge, Ltd. | 4 | Challenges of Unit Testing Why did not you create (enough) unit test in your last project? We barely have time to write code, no spare time to waste on tests Our code runs in a complicated container and cannot be tested alone Input format is complex and it's hard to create one for a test Output format is complex and it's hard to verify one for a test

5 Copyright 2007 Tikal Knowledge, Ltd. | 5 | Challenges of Unit Testing Why did not you create (enough) unit test in your last project? We barely have time to write code, no spare time to waste on tests Our code runs in a complicated container and cannot be tested alone Input format is complex and it's hard to create one for a test Output format is complex and it's hard to verify one for a test We have enough open bugs already, didn't want to find even more with new tests

6 Copyright 2007 Tikal Knowledge, Ltd. | 6 | Importance of tools We barely have time to write code, no spare time to waste on tests [Test] is easier than main! Our code runs in a complicated container and cannot be tested alone Input format is complex and it's hard to create one for a test Output format is complex and it's hard to verify one for a test We have enough open bugs already, didn't want to find even more with new tests

7 Copyright 2007 Tikal Knowledge, Ltd. | 7 | Importance of tools [Test] is easier than main! Our code runs in a complicated container and cannot be tested alone Simulate container! Input format is complex and it's hard to create one for a test Output format is complex and it's hard to verify one for a test We have enough open bugs already, didn't want to find even more with new tests

8 Copyright 2007 Tikal Knowledge, Ltd. | 8 | Importance of tools [Test] is easier than main! Simulate container! Input format is complex and it's hard to create one for a test Record actual input! Output format is complex and it's hard to verify one for a test We have enough open bugs already, didn't want to find even more with new tests

9 Copyright 2007 Tikal Knowledge, Ltd. | 9 | Importance of tools [Test] is easier than main! Simulate container! Record actual input! Output format is complex and it's hard to verify one for a test Use sophisticated verifiers! We have enough open bugs already, didn't want to find even more with new tests

10 Copyright 2007 Tikal Knowledge, Ltd. | 10 | Importance of tools [Test] is easier than main! Simulate container! Record actual input! Use sophisticated verifiers! We have enough open bugs already, didn't want to find even more with new tests Not all bugs have to be fixed!

11 Copyright 2007 Tikal Knowledge, Ltd. | 11 | Agenda Introduction Visual Studio built-in support Open source frameworks Working together Unit testing in real life Summary

12 Copyright 2007 Tikal Knowledge, Ltd. | 12 | Visual Studion built-in support Attribute based » [TestClass] » [TestMethod] Classic Assert syntax » AssertEquals(4, 2+2) Data driven tests » [DataSource]

13 Copyright 2007 Tikal Knowledge, Ltd. | 13 | Demo

14 Copyright 2007 Tikal Knowledge, Ltd. | 14 | Agenda Introduction Visual Studio built-in support Open source frameworks Working together Unit testing in real life Summary

15 Copyright 2007 Tikal Knowledge, Ltd. | 15 | NUnit Proven technology since 2002 Categories Classic and constraint based asserts » Demo User created contstraints » Demo Data-driven tests » Demo pNUnit for parallel execution » Demo

16 Copyright 2007 Tikal Knowledge, Ltd. | 16 | Other.Net open source test frameworks mbUnit aka Gallio xUnit.net csUnit

17 Copyright 2007 Tikal Knowledge, Ltd. | 17 | Working together: MSTest and NUnit cooperation MSTest cases can run under Nunit » http://www.exactmagic.com/products/mstest/ http://www.exactmagic.com/products/mstest/ NUnit tests can run under Team Foundation » http://www.codeplex.com/nunit4teambuild http://www.codeplex.com/nunit4teambuild Demo

18 Copyright 2007 Tikal Knowledge, Ltd. | 18 | Unit testing in real life: how to start? Selecting framework Creating comfortable environment Writing first tests Improving the coverage Performance testing

19 Copyright 2007 Tikal Knowledge, Ltd. | 19 | ALM and Unit Testing Build without tests is next to nonsense Refactoring without tests is disaster Merge without tests is gambling Last known good without tests is not known

20 Copyright 2007 Tikal Knowledge, Ltd. | 20 | Maintaining test suites Before the release » Bad tests may be ignored » Known bugs are reassigned to the next version » Hopefully, some bugs will be fixed After the release » Fix bad tests » Review known bugs, separate complex bugs into simpler ones » Check coverage Mid-cycle » Improve test infrastructure to lower false positives » Adopt/develop measurement tools to track team bottlenecks

21 Copyright 2007 Tikal Knowledge, Ltd. | 21 | Summary Unit tests are essential With appropriate infrastructure and tools they are fun to create and maintain Unit tests can and should speed up development Non technical reasons to use unit tests

22 Copyright 2007 Tikal Knowledge, Ltd. | 22 | Q & A

23 Copyright 2007 Tikal Knowledge, Ltd. | 23 | Thank you


Download ppt "Unit testing in.Net. Copyright 2007 Tikal Knowledge, Ltd. | 2 | Agenda Introduction Visual Studio built-in support Open source frameworks Working together."

Similar presentations


Ads by Google