第三次作业单元测试

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);
    }
}

 

posted @ 2015-04-30 18:32  46-罗伟业  阅读(131)  评论(1编辑  收藏  举报