Your SlideShare is downloading. ×
0
Unit testing and test driven development using vs
Unit testing and test driven development using vs
Unit testing and test driven development using vs
Unit testing and test driven development using vs
Unit testing and test driven development using vs
Unit testing and test driven development using vs
Unit testing and test driven development using vs
Unit testing and test driven development using vs
Unit testing and test driven development using vs
Unit testing and test driven development using vs
Unit testing and test driven development using vs
Unit testing and test driven development using vs
Unit testing and test driven development using vs
Unit testing and test driven development using vs
Unit testing and test driven development using vs
Unit testing and test driven development using vs
Unit testing and test driven development using vs
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Unit testing and test driven development using vs

2,199

Published on

Published in: Technology, Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,199
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Unit Testing and Test Driven Development Using VS 2010<br />Abhimanyu Singhal<br />Lead Consultant<br />iMentor Knowledge Services<br />
  • 2. Introduce Unit Testing Features<br />How to create Team Test unit tests.<br />Generating the unit test method stubs for an assembly<br />Using a test driven development (TDD)<br />Objectives<br />
  • 3. Thinking about tests pushes developer to understand better the gathered requirements<br />Reduces the over engineered code (dead code)<br />Unit Tests help to check that any new modification wont break the existing features.<br />TDD increases software flexibility<br />TDD code is more decoupled<br />Why is TDD Good<br />
  • 4. A Visual Studio integrated unit-testing framework<br />Code generation of test method stubs. <br />Running tests within the IDE. <br />Incorporation of test data loaded from a database. <br />Code coverage analysis once the tests have run. <br />Visual Studio Team Test<br />
  • 5. Designates a Method as a Test Method<br />Found in Microsoft.VisualStudio.QualityTools.UnitTesting.Framework Namespace<br />TestMethod has to be an instance method with no paramters<br />Method name is irrelevant because reflection searches for TestMethod Attribute<br />TestMethodAttribute Class<br />
  • 6. Class containing the test method is designated TestClass Attribute<br /><ul><li>Found in Microsoft.VisualStudio.QualityTools.UnitTesting.Framework Namespace
  • 7. Team Test Uses Reflection to find Class with TestClass Attribute and Method with TestMethod Attribute and runs it</li></ul>TestClassAttribute Class<br />
  • 8. From Visual Studio<br />As Part of Build Process<br />From Command Line<br />Running and Executing Tests<br />
  • 9. Takes a Parameter which is Exception Type to watch for<br />If Exception does not occur test fails<br />The Second parameter (string) is optional is the error message displayed when exception is not thrown<br />ExpectedException Attribute<br />
  • 10. Use Test Properties Window<br />Add TestData Attribute<br />Source Type<br />Connection String<br />TableName<br />DataAccessMethod<br />Loading Test Data From Database<br />
  • 11. Provides associated data through <br />DataRow Property<br />TestDirectory, TestName<br />Mesuring Test Time using <br />BeingTimer() <br />EndTimer()<br />The TestContext<br />
  • 12. Determines how much code is tested<br />Shows Percentage of Code Executed<br />Highlights code to show which lines are executed<br />Code Coverage<br />
  • 13. TestInitialize Attribute<br />TestCleanup Attribute<br />Code to be run before and after each test method<br />Other Attributes for Lifetime Methods<br />AssemblyInitializeAttribute/AssemblyCleanupAttribute<br />ClassInitializeAttribute/ClassCleanupAttribute.<br />Initializing and Cleaning Up Tests<br />
  • 14. The Testing Framework<br />
  • 15. Keep Testing Code in Separate Assemblies<br />Check for cleanup during test setup and execute the cleanup prior to the setup as necessary<br />Avoid creating dependencies between tests, each test should be autonomous. <br />Create one test class corresponding to each class within the production code.<br />Avoid creating other machine dependent tests<br />Create mock objects to test interfaces<br />Guidance – Unit Testing<br />
  • 16. To update the attendance for the session and obtain learning credits log on to https://ch1workspaces/sites/SW23/MS_Course_nominations/default.aspx<br />Question and Answers Session<br />
  • 17. Thank You<br />abhimanyu@imentor.co.in<br />@abhi_singhal<br />http://www.imentor.co.in/blog<br />
  • 18. iMentor Knowledge Services<br />

×