unit testing in.net. copyright 2007 tikal knowledge, ltd. | 2 | agenda introduction visual studio...
TRANSCRIPT
![Page 1: Unit testing in.Net. Copyright 2007 Tikal Knowledge, Ltd. | 2 | Agenda Introduction Visual Studio built-in support Open source frameworks Working together](https://reader036.vdocument.in/reader036/viewer/2022062618/5514321c5503466d1a8b509e/html5/thumbnails/1.jpg)
Unit testing in .Net
![Page 2: Unit testing in.Net. Copyright 2007 Tikal Knowledge, Ltd. | 2 | Agenda Introduction Visual Studio built-in support Open source frameworks Working together](https://reader036.vdocument.in/reader036/viewer/2022062618/5514321c5503466d1a8b509e/html5/thumbnails/2.jpg)
Copyright 2007 Tikal Knowledge, Ltd. | 2 |
AgendaAgenda
Introduction Visual Studio built-in support Open source frameworks Working together Unit testing in real life Summary
![Page 3: Unit testing in.Net. Copyright 2007 Tikal Knowledge, Ltd. | 2 | Agenda Introduction Visual Studio built-in support Open source frameworks Working together](https://reader036.vdocument.in/reader036/viewer/2022062618/5514321c5503466d1a8b509e/html5/thumbnails/3.jpg)
Copyright 2007 Tikal Knowledge, Ltd. | 3 |
Introduction: importance of unit testingIntroduction: importance of unit testing
Better software quality Faster development cycles Easier refactoring Finer granularity of commits Easier measurement of progress
![Page 4: Unit testing in.Net. Copyright 2007 Tikal Knowledge, Ltd. | 2 | Agenda Introduction Visual Studio built-in support Open source frameworks Working together](https://reader036.vdocument.in/reader036/viewer/2022062618/5514321c5503466d1a8b509e/html5/thumbnails/4.jpg)
Copyright 2007 Tikal Knowledge, Ltd. | 4 |
Challenges of Unit TestingChallenges 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
![Page 5: Unit testing in.Net. Copyright 2007 Tikal Knowledge, Ltd. | 2 | Agenda Introduction Visual Studio built-in support Open source frameworks Working together](https://reader036.vdocument.in/reader036/viewer/2022062618/5514321c5503466d1a8b509e/html5/thumbnails/5.jpg)
Copyright 2007 Tikal Knowledge, Ltd. | 5 |
Challenges of Unit TestingChallenges 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
![Page 6: Unit testing in.Net. Copyright 2007 Tikal Knowledge, Ltd. | 2 | Agenda Introduction Visual Studio built-in support Open source frameworks Working together](https://reader036.vdocument.in/reader036/viewer/2022062618/5514321c5503466d1a8b509e/html5/thumbnails/6.jpg)
Copyright 2007 Tikal Knowledge, Ltd. | 6 |
Importance of toolsImportance 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
![Page 7: Unit testing in.Net. Copyright 2007 Tikal Knowledge, Ltd. | 2 | Agenda Introduction Visual Studio built-in support Open source frameworks Working together](https://reader036.vdocument.in/reader036/viewer/2022062618/5514321c5503466d1a8b509e/html5/thumbnails/7.jpg)
Copyright 2007 Tikal Knowledge, Ltd. | 7 |
Importance of toolsImportance 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
![Page 8: Unit testing in.Net. Copyright 2007 Tikal Knowledge, Ltd. | 2 | Agenda Introduction Visual Studio built-in support Open source frameworks Working together](https://reader036.vdocument.in/reader036/viewer/2022062618/5514321c5503466d1a8b509e/html5/thumbnails/8.jpg)
Copyright 2007 Tikal Knowledge, Ltd. | 8 |
Importance of toolsImportance 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
![Page 9: Unit testing in.Net. Copyright 2007 Tikal Knowledge, Ltd. | 2 | Agenda Introduction Visual Studio built-in support Open source frameworks Working together](https://reader036.vdocument.in/reader036/viewer/2022062618/5514321c5503466d1a8b509e/html5/thumbnails/9.jpg)
Copyright 2007 Tikal Knowledge, Ltd. | 9 |
Importance of toolsImportance 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
![Page 10: Unit testing in.Net. Copyright 2007 Tikal Knowledge, Ltd. | 2 | Agenda Introduction Visual Studio built-in support Open source frameworks Working together](https://reader036.vdocument.in/reader036/viewer/2022062618/5514321c5503466d1a8b509e/html5/thumbnails/10.jpg)
Copyright 2007 Tikal Knowledge, Ltd. | 10 |
Importance of toolsImportance 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!
![Page 11: Unit testing in.Net. Copyright 2007 Tikal Knowledge, Ltd. | 2 | Agenda Introduction Visual Studio built-in support Open source frameworks Working together](https://reader036.vdocument.in/reader036/viewer/2022062618/5514321c5503466d1a8b509e/html5/thumbnails/11.jpg)
Copyright 2007 Tikal Knowledge, Ltd. | 11 |
AgendaAgenda
Introduction Visual Studio built-in support Open source frameworks Working together Unit testing in real life Summary
![Page 12: Unit testing in.Net. Copyright 2007 Tikal Knowledge, Ltd. | 2 | Agenda Introduction Visual Studio built-in support Open source frameworks Working together](https://reader036.vdocument.in/reader036/viewer/2022062618/5514321c5503466d1a8b509e/html5/thumbnails/12.jpg)
Copyright 2007 Tikal Knowledge, Ltd. | 12 |
Visual Studion built-in supportVisual Studion built-in support
Attribute based» [TestClass]» [TestMethod]
Classic Assert syntax» AssertEquals(4, 2+2)
Data driven tests» [DataSource]
![Page 13: Unit testing in.Net. Copyright 2007 Tikal Knowledge, Ltd. | 2 | Agenda Introduction Visual Studio built-in support Open source frameworks Working together](https://reader036.vdocument.in/reader036/viewer/2022062618/5514321c5503466d1a8b509e/html5/thumbnails/13.jpg)
Copyright 2007 Tikal Knowledge, Ltd. | 13 |
DemoDemo
![Page 14: Unit testing in.Net. Copyright 2007 Tikal Knowledge, Ltd. | 2 | Agenda Introduction Visual Studio built-in support Open source frameworks Working together](https://reader036.vdocument.in/reader036/viewer/2022062618/5514321c5503466d1a8b509e/html5/thumbnails/14.jpg)
Copyright 2007 Tikal Knowledge, Ltd. | 14 |
AgendaAgenda
Introduction Visual Studio built-in support Open source frameworks Working together Unit testing in real life Summary
![Page 15: Unit testing in.Net. Copyright 2007 Tikal Knowledge, Ltd. | 2 | Agenda Introduction Visual Studio built-in support Open source frameworks Working together](https://reader036.vdocument.in/reader036/viewer/2022062618/5514321c5503466d1a8b509e/html5/thumbnails/15.jpg)
Copyright 2007 Tikal Knowledge, Ltd. | 15 |
NUnitNUnit
Proven technology since 2002 Categories Classic and constraint based asserts
» Demo
User created contstraints» Demo
Data-driven tests» Demo
pNUnit for parallel execution» Demo
![Page 16: Unit testing in.Net. Copyright 2007 Tikal Knowledge, Ltd. | 2 | Agenda Introduction Visual Studio built-in support Open source frameworks Working together](https://reader036.vdocument.in/reader036/viewer/2022062618/5514321c5503466d1a8b509e/html5/thumbnails/16.jpg)
Copyright 2007 Tikal Knowledge, Ltd. | 16 |
Other .Net open source test frameworksOther .Net open source test frameworks
mbUnit aka Gallio xUnit.net csUnit
![Page 17: Unit testing in.Net. Copyright 2007 Tikal Knowledge, Ltd. | 2 | Agenda Introduction Visual Studio built-in support Open source frameworks Working together](https://reader036.vdocument.in/reader036/viewer/2022062618/5514321c5503466d1a8b509e/html5/thumbnails/17.jpg)
Copyright 2007 Tikal Knowledge, Ltd. | 17 |
Working together: MSTest and NUnit Working together: MSTest and NUnit cooperationcooperation
MSTest cases can run under Nunit» http://www.exactmagic.com/products/mstest/
NUnit tests can run under Team Foundation» http://www.codeplex.com/nunit4teambuild
Demo
![Page 18: Unit testing in.Net. Copyright 2007 Tikal Knowledge, Ltd. | 2 | Agenda Introduction Visual Studio built-in support Open source frameworks Working together](https://reader036.vdocument.in/reader036/viewer/2022062618/5514321c5503466d1a8b509e/html5/thumbnails/18.jpg)
Copyright 2007 Tikal Knowledge, Ltd. | 18 |
Unit testing in real life: how to start?Unit testing in real life: how to start?
Selecting framework Creating comfortable environment Writing first tests Improving the coverage Performance testing
![Page 19: Unit testing in.Net. Copyright 2007 Tikal Knowledge, Ltd. | 2 | Agenda Introduction Visual Studio built-in support Open source frameworks Working together](https://reader036.vdocument.in/reader036/viewer/2022062618/5514321c5503466d1a8b509e/html5/thumbnails/19.jpg)
Copyright 2007 Tikal Knowledge, Ltd. | 19 |
ALM and Unit TestingALM 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
![Page 20: Unit testing in.Net. Copyright 2007 Tikal Knowledge, Ltd. | 2 | Agenda Introduction Visual Studio built-in support Open source frameworks Working together](https://reader036.vdocument.in/reader036/viewer/2022062618/5514321c5503466d1a8b509e/html5/thumbnails/20.jpg)
Copyright 2007 Tikal Knowledge, Ltd. | 20 |
Maintaining test suitesMaintaining 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
![Page 21: Unit testing in.Net. Copyright 2007 Tikal Knowledge, Ltd. | 2 | Agenda Introduction Visual Studio built-in support Open source frameworks Working together](https://reader036.vdocument.in/reader036/viewer/2022062618/5514321c5503466d1a8b509e/html5/thumbnails/21.jpg)
Copyright 2007 Tikal Knowledge, Ltd. | 21 |
SummarySummary
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
![Page 22: Unit testing in.Net. Copyright 2007 Tikal Knowledge, Ltd. | 2 | Agenda Introduction Visual Studio built-in support Open source frameworks Working together](https://reader036.vdocument.in/reader036/viewer/2022062618/5514321c5503466d1a8b509e/html5/thumbnails/22.jpg)
Copyright 2007 Tikal Knowledge, Ltd. | 22 |
Q & AQ & A
![Page 23: Unit testing in.Net. Copyright 2007 Tikal Knowledge, Ltd. | 2 | Agenda Introduction Visual Studio built-in support Open source frameworks Working together](https://reader036.vdocument.in/reader036/viewer/2022062618/5514321c5503466d1a8b509e/html5/thumbnails/23.jpg)
Copyright 2007 Tikal Knowledge, Ltd. | 23 |
Thank youThank you