Wednesday, June 19, 2013

JUnit Sampler Tutorial- JMeter



 In Eclipse, you export file sem.jar and saving this file into : D:\ \apache-jmeter-2.9\lib\junit\

Example code:

package com.example;

import org.junit.Test;

import junit.framework.TestCase;

public class Test1 extends TestCase{
      int a=10,b=5;

      int c,d,e;
     
      @Test
      public void testsum()
     
      {
            c=a+b;
            System.out.println("The Sum of two numbers is: " +c);

      }
      @Test
      public void testmulti()

      {

      d=a*b;

      System.out.println("The product of two numbers is: " +d);

      }
      @Test
      public void testdiv()

      {

      e=a/b;

      System.out.println("The division of two numbers is: " +e);

      }
     
}



  In Jmeter;

  • This will start the jmeter
    •  ON the Right side you will see the TestPlan
    •  Right Click on TestPlan->Add->Threads->Thread Group
    •  Enter Thread Name and Thread Properties
    •  Click on Save
  •  Right Click on Thread Group->Add->Sampler->Junit request
    •  Enter Name
    •  Select Junit Class
    •  Select Method
    • Click on Save

       







        


      Click on Junit Request->Add->Listerner->View Result as a Table
       

      HoaLe

No comments:

Post a Comment