第三次作业单元测试

package com.hui.demo.test;

import static org.junit.Assert.*;
import org.junit.Test;
import com.hui.demo.Core;

public class CoreTest {

    @Test
    public void testAdd() {
        Core core = new Core();
        
        long a = core.add(10,-3);
        assertEquals(4L, a); 
    }
    
    @Test
    public void testAddisOverLimited() {
        Core core = new Core();
        long a = core.add(2147483647,2147483647);
        assertEquals(4294967294L, a);
    }
}
package com.hui.demo.test;

import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.hui.demo.Core;

public class CoreTest {
        
        @Test
    public void testDivide() {
        Core core = new Core();
        int result = core.divide(3, 2);
        assertEquals(1, result);
    }
    
        @Test(expected=ArithmeticException.class)
    public void testDivideZero()  {
        Core core = new Core();
        core.divide(2, 0);
    }
}

 

你可能感兴趣的:(单元测试)