之前一篇博文(JUnit基础及第一个单元测试实例(JUnit3.8))介绍了用JUnit做单元测试的基本方法,并写了一个简单的类Calculator,其中包含了整型加减乘除的简单算法. 本文通过完善其中的除法和除法的单元测试来继续说明JUnit的用法. 首先完善Calculator类中的除法,在除数为零的情况下抛出一个异常: public int divide(int a, int b) throws Exception { if(0 == b) { throw new Exception("除
目的是要跑通这个单元测试:hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestClose.java 这个Java文件比较简单: /** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for