• Save
Unit testing and test driven development using vs
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Unit testing and test driven development using vs

on

  • 2,639 views

 

Statistics

Views

Total Views
2,639
Views on SlideShare
2,031
Embed Views
608

Actions

Likes
1
Downloads
0
Comments
0

3 Embeds 608

http://www.imentor.co.in 474
http://www.i-softindia.com 121
http://imentor.co.in 13

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Unit testing and test driven development using vs Presentation Transcript

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