首页 > 其他 > 详细

个人项目

时间:2015-04-27 12:32:27      阅读:105      评论:0      收藏:0      [点我收藏+]

https://github.com/tengjuan/Individual-Project/blob/master/CalculatorTest

 

编写一个Calculator类,这是一个能够简单实现加减乘除、平方、开方的计算器类,然后对这些功能进行单元测试。

 

package andycpp;
import static org.junit.Assert.*;
import org.junit.Before;
 import org.junit.Ignore;
import org.junit.Test;
public class CalculatorTest {
    private static Calculator calculator = new Calculator();
    @Before
    public void setUp() throws Exception {   
     calculator.clear();  
  }
    @Test
    public void testAdd() {
        calculator.add(2);
        calculator.add(3);
        assertEquals(5, calculator.getResult()); 
   }  
    @Test
    public void testSubstract()
  {       
       calculator.add(10);   
       calculator.substract(2);
        assertEquals(8, calculator.getResult()); 
   }
    @Ignore(" Multiply() Not yet implemented")
 @Test
    public void testMultiply() {  
  }
    @Test
    public void testDivide() {      
       calculator.add(8);      
       calculator.divide(2);
        assertEquals(4, calculator.getResult());   
 }
 }

技术分享

 总结:通过这个实验,了解一些软件测试的基本含义,学会了一些基本测试的步骤的设计和用例的构造。初步学会了junit4的使用,了解到基本流程和实现。

个人项目

原文:http://www.cnblogs.com/tj1024/p/4459500.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!