第三次作业单元测试 46

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);
    }
}
原文地址:https://www.cnblogs.com/qq1076529919/p/4469615.html