Tuesday, June 10, 2014

Junit test for testing methods of Java

package junit_test;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author Sakib
 */
public class UtilsTest {
 
    public UtilsTest() {
    }
 
    @BeforeClass
    public static void setUpClass() {
    }
 
    @AfterClass
    public static void tearDownClass() {
    }
 
    @Before
    public void setUp() {
    }
 
    @After
    public void tearDown() {
    }

        /**
     * Test of percentage calculate, of class Utils.
     */
    @Test
    public void testgetPercent() {
     
        double rate = 10;
        double amount = 500;
        double expResult = 50;
        double result = Utils.percentage(rate,amount);
        assertEquals(expResult, result,2);
          }
 
}
Result :Test Passed

No comments:

Post a Comment