Dinuka Malinda Peiris Malalanayake
Associate QA Engineer -Excel Technology Lanka
BACKGROUND
 What is an Unit testing?
 About Nunit.




                                        “Any Unit Test is better than none”
 How to do the Unit testing with C#?

 Nunit Assertion.

 Nunit Attributes.

 Best Practice

 Advantages

 Disadvantages

 Similar Products.
WHAT IS AN UNIT TESTING?
 A unit test is a procedure used to verify that a
  particular module of source code is working




                                                     “Any Unit Test is better than none”
  properly
 Company wants to achieve three related goals
     Faster time-to-market
     Higher quality
     More flexibility
ABOUT NUNIT.
 NUnit is an open source unit testing
  framework for Microsoft.NET.




                                                “Any Unit Test is better than none”
 It serves the same purpose as JUnit does in
  the Java world, and is one of many in
  the xUnit family
 Provide both GUI and Console
HOW TO DO THE UNIT TESTING WITH C#?




                                      “Any Unit Test is better than none”
NUNIT ASSERTION
 Equality
 Identity




                  “Any Unit Test is better than none”
 Comparison

 Condition

 String
NUNIT ATTRIBUTES
 Test Fixture
 Test




                                 “Any Unit Test is better than none”
 Setup
 Teardown
 Test Fixture Setup/ Teardown
 Expected Exception
 Platform
 Category
 Explicit
 Suite
 Ignore
BEST PRACTICE
 No conditional logic – Switch, if
 No loops




                                      “Any Unit Test is better than none”
 No exception catching

 Use appropriate method names

 Informative assertion message

 Separation per type
ADVANTAGES
 Fast
 Test Isolation




                                                      “Any Unit Test is better than none”
 Environment Isolation – Use Mock Objects

 Unit testing gives you a safety net when
  programmers refactor or add functionality
 Unit tests can be used as documentation for other
  programmers
 Development process becomes more flexible
DISADVANTAGES
   Unnecessary Unit Tests can lead to considerably
    high maintenance cost to your overall project




                                                      “Any Unit Test is better than none”
SIMILAR PRODUCTS
Programming Language   Unit Testing Tool
Java – J2SE / J2EE     Junit
Java – J2ME




                                           “Any Unit Test is better than none”
                       JMUnit
C                      CUnit
C++                    CppUnit
php                    PHPUnit
Python                 PyUnit / py.test

Nunit

  • 1.
    Dinuka Malinda PeirisMalalanayake Associate QA Engineer -Excel Technology Lanka
  • 2.
    BACKGROUND  What isan Unit testing?  About Nunit. “Any Unit Test is better than none”  How to do the Unit testing with C#?  Nunit Assertion.  Nunit Attributes.  Best Practice  Advantages  Disadvantages  Similar Products.
  • 3.
    WHAT IS ANUNIT TESTING?  A unit test is a procedure used to verify that a particular module of source code is working “Any Unit Test is better than none” properly  Company wants to achieve three related goals  Faster time-to-market  Higher quality  More flexibility
  • 4.
    ABOUT NUNIT.  NUnitis an open source unit testing framework for Microsoft.NET. “Any Unit Test is better than none”  It serves the same purpose as JUnit does in the Java world, and is one of many in the xUnit family  Provide both GUI and Console
  • 5.
    HOW TO DOTHE UNIT TESTING WITH C#? “Any Unit Test is better than none”
  • 6.
    NUNIT ASSERTION  Equality Identity “Any Unit Test is better than none”  Comparison  Condition  String
  • 7.
    NUNIT ATTRIBUTES  TestFixture  Test “Any Unit Test is better than none”  Setup  Teardown  Test Fixture Setup/ Teardown  Expected Exception  Platform  Category  Explicit  Suite  Ignore
  • 8.
    BEST PRACTICE  Noconditional logic – Switch, if  No loops “Any Unit Test is better than none”  No exception catching  Use appropriate method names  Informative assertion message  Separation per type
  • 9.
    ADVANTAGES  Fast  TestIsolation “Any Unit Test is better than none”  Environment Isolation – Use Mock Objects  Unit testing gives you a safety net when programmers refactor or add functionality  Unit tests can be used as documentation for other programmers  Development process becomes more flexible
  • 10.
    DISADVANTAGES  Unnecessary Unit Tests can lead to considerably high maintenance cost to your overall project “Any Unit Test is better than none”
  • 11.
    SIMILAR PRODUCTS Programming Language Unit Testing Tool Java – J2SE / J2EE Junit Java – J2ME “Any Unit Test is better than none” JMUnit C CUnit C++ CppUnit php PHPUnit Python PyUnit / py.test