• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content

Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Like this presentation? Why not share!

RIA 05 - Unit Testing by Ajinkya Prabhune

on

  • 871 views

guest presentation

guest presentation

Statistics

Views

Total Views
871
Views on SlideShare
756
Embed Views
115

Actions

Likes
0
Downloads
32
Comments
0

1 Embed 115

http://blog.johanneshoppe.de 115

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

    RIA 05 - Unit Testing by Ajinkya Prabhune RIA 05 - Unit Testing by Ajinkya Prabhune Presentation Transcript

    • Unit Testing
      By AjinkyaPrabhune
    • What is Unit Testing ?
      Example.
      When to use Unit Testing ?
      How to write Unit Test ?
      FrameWorks Examples.
      Agenda
    • The primary goal of unit testing is to take the smallest piece of testable software in the application, isolate it from the remainder of the code, and determine whether it behaves exactly as you expect.
      Good Definition for Unit Test- (define later)
      Unit Test is an automated piece of code that invokes the method or class being tested and then check some assumption about the logical behavior of that Method/Class. Unit Test is almost always written using a Unit Testing Framework. It can be written easily & runs quickly.
      It is fully automated, trustworthy, readable and maintainable.
      What is Unit Testing
    • Assume we have a Addition class that we’d like to test.
      We can now create a simple test class which will call this method.
      MathOperation operation = new MathOperation();
      operation.Addition(3,4)
      value = 7 should be expected for a successful Test.
      Example
      public class MathOperation
      {
      public int Addition(int a, int b)
      {
      if(a==null || b==null)
      {
      System.Out.Println(“Null value occured”)
      return -1;
      }
      else
      {
      return a+b;
      }
      }
      }
    • 1 . It helps you write better Code.
      In addition to finding errors in your code, unit testing can help you during the initial development of your class or module's public interface.
      Unit tests force you to think about how another developer will want to use your code while you're writing that code.
      2. Writing test cases will save you time later.
      3. Unit tests provide immediate feedback on your code.
      You don't have to wait until after code in a separate part of the application is written before you can test and know whether your code works.
      4. Unit Tests should be written at each stage of development of your code.
      so that continuous check of your code is maintained and saves you efforts during the final release of the software.
      Why/When to use Unit Test.
    • The Tests should be Through.
      1. You should only be satisfied with your unit tests when
      you’re confident that your unit tests thoroughly verify that
      your code works as we expect it to work.
      2. Unit tests should exercise the expected as well as the
      unexpected conditions in your code.
      3. Special attention should be paid to areas of code that are
      particularly likely to break.
      How to write Unit test ?
    • The Test should be Repeatable.
      1. Every one of your unit tests should be able to be
      run repeatedly and continue to produce the same
      results, regardless of the environment in which the
      tests are being run.
      2. Your unit tests should not rely on hard-coded
      server urls.
      3. Unit tests must be written in either a sandbox org
      or in a developer org.
      Cont…
    • The Test should be Independent
      1. Your unit tests should only test one aspect of your code at a time, so that it is easy to understand the purpose of each unit test. Properly written, and well-decomposed unit tests are an excellent source of documentation.
      2. Each Test should be independent of the other Test.
      Cont…
    • Junit – JAVA
      Nunit- .Net
      FrameWorks of Unit Testing
    • Thank you