Unit testing

797 views

Published on

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
797
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Unit testing

  1. 1. Unit Testing Saranya.V AP/CSE,Sri Vidya College of Engineering & Technology, Virudhunagar
  2. 2. Definition• The smallest piece of code software that can be tested in isolation.
  3. 3. This is a Unit• public class MyMath• {• public int Add(int i, int j)• {• return i + j;• }• }
  4. 4. This is a Unit Test• public void MyAddTest()• {• MyMath m = new MyMath();• Assert.AreEqual(m.Add(2, 3), 5);• }
  5. 5. Unit Test Considerations Interface Module Local Data Structure ------------ Boundary Condition ------------ Error Handling Paths ------------ Independent Paths -------------------------- Test Cases
  6. 6. Unit Test Procedure• In order to start a unit test, we need a complete environment to provide all the necessary things. Driver Interface Module to Local Data Structure be tested Boundary Condition Error Handling Paths Independent Paths Stub Stub Results Test Cases
  7. 7. • Stubs and drivers are used to provide a complete environment.• Stub is a dummy procedure.• Stub may produce the expected behavior using a simple table look up mechanism.• Driver module contains Non Local Data Structure.
  8. 8. Driver Module Global data Module Under Test Stub ModuleUnit test follows high cohesion.Reduced number of test cases.

×