Dave Lloyd Unit Testing in the Real World.
-
Upload
ira-cooper -
Category
Documents
-
view
223 -
download
0
Transcript of Dave Lloyd Unit Testing in the Real World.
Dave Lloydwww.ObjectSharp.com/Blogs/Dave
Unit Testing in the Real World
AgendaAgenda
Anatomy of a Test FixtureBeware of the .VSMDIUsing the .testrunconfigExpected ExceptionsData Driven TestsMock ObjectsIgnore & InconclusiveTest Driven DevelopmentStatic Code Analysis and Code Coverage
Anatomy of a TestFixture
Test Class<TestClass><ClassInitialize()> and <ClassCleanup()><TestInitialize()> and <TestCleanup()>
Test Method<TestMethod()>
TestContext Property
.VSMDI
Meta Data for Test ManagerMust have VS for Testers or Team SuiteNot a part of VS for Developers
Don’t Merge this file!To add tests to a Team Build you need this file
.testrunconfig
Creating and using your ownDeploymentCode CoverageSetup and Cleanup Batch Files
Testing for Expected Exceptions
ExpectedException AttributeValidate the correct Exception was raised
Data Driven Tests
DataSource AttributeExecute a test using test data
Mock Objects
The Crash Test Dummies of Unit TestingSimulated ObjectSame Interface as the Real Object
Why Create a Mock ObjectReal one doesn’t exist yetDifficult to produce within a test
Ignore & Inconclusive
IgnoreTell VSTS to ignore a test
Assert.InconclusiveShow test in test results with messageReminder of an Inconclusive Test
Test Driven Development
Available in C#The Process
Write a Test Execute and see it failWrite the codeExecute the test and see it pass
Smart Tag allowing you to Generate a method Stub in the code being tested
Code Coverage
Static Code Analysis
AdditionalResources
Blogs on TDD:• James Newkirk - blogs.msdn.com/jamesnewkirk• Brian Marick - www.testing.com/cgi-bin/blog• Jonathan de Halleux - http://blog.dotnetwiki.org/ • Jose Almeida - blogs.msdn.com/josealmeida/• Scott Densmore – blogs.msdn.com/scottdensmore• Code Project -www.codeproject.com/dotnet/tdd_in_dotnet.asp• TestDriven.com - www.testdriven.com
Books:• Test-Driven Development in Microsoft.Net
By James W. Newkirk & Alexei A. Vorontsov• Test Driven Development: A Practical Guide
By David Astels• Test Driven Development: by Example
By Kent Beck
Unit Testing in the Real World
Dave LloydPartner, ObjectSharp Consultingwww.ObjectSharp.com/Blogs/Dave
Unit Testing in the Real World
Dave Lloydwww.ObjectSharp.com/Blogs/Dave