zoukankan      html  css  js  c++  java
  • Junit单元测试

    package com.ss1.junit;
    
    public class Calculator {
    
        public int add(int one, int another) {
            // 为了简单起见,暂不考虑溢出等情况。
            return one + another;
        }
    
        public int multiply(int one, int another) {
            // 为了简单起见,暂不考虑溢出等情况。
            return one * another;
        }
        
    }
    package com.ss1.junit;
    
    import static org.junit.Assert.*;
    
    import org.junit.Before;
    import org.junit.Ignore;
    import org.junit.Test;
    
    public class CalculatorTest {
        
        private Calculator calculator;
    
        @Before
        public void setUp() throws Exception {
            calculator = new Calculator();
        }
    
    /*    @Test
        public void test() {
            fail("Not yet implemented");
        }
    */
        @Test
        public void testAdd() throws Exception{
            int sum = calculator.add(1,2);
             assertEquals(3, sum);
        }
        
        @Test
        public void testMultipy() throws Exception{
            int product = calculator.multiply(2,4);
             assertEquals(9, product);
        }
        @Test
        @Ignore("not implemented yet")//该方法未完成,跳过对此方法的验证
        public void testIgnore() throws Exception{
            
        }
    }
  • 相关阅读:
    Spring5源码分析之Bean生命周期
    关系图
    Spring5源码分析之AnnotationConfigApplicationContext
    Spring中好玩的注解和接口
    MyBatis使用总结
    设计模式的应用
    C#:网络传输问题
    工具软件:
    Rar安装包
    C#:注册组件 (cmd)
  • 原文地址:https://www.cnblogs.com/tingbogiu/p/5753164.html
Copyright © 2011-2022 走看看