Hadoop 0.21如何运行单个test case

        研究Hadoop 0.21代码时,很多情况下需要运行单个test case,如果新增了功能要测试case能否通过或者自己写的test case需要测试等。而把test case全部运行一遍是很耗时的,严重影响开发效率。这里提供一个0.21 mapreduce的一个diff文件,用以修改build.xml文件,打上patch后即可在本地运行单个test case了。

Index: build.xml
===================================================================
--- build.xml	(revision 1102542)
+++ build.xml	(working copy)
@@ -685,6 +685,7 @@
                      value="@{hadoop.conf.dir.deployed}" />
         <classpath refid="@{classpath}"/>
         <formatter type="${test.junit.output.format}" />
+        <test name="${testcase}" todir="${test.build.dir}" if="testcase"/>
         <batchtest todir="@{test.dir}" unless="testcase">
           <fileset dir="@{fileset.dir}/@{suite.type}"
             excludes="**/${test.exclude}.java aop/** system/**">
@@ -776,7 +777,18 @@
       fileset.dir="${test.src.dir}"/>
    </target>
 
+  <target name="run-ut"
+    depends="compile-mapred-test" if="testcase">
+    <macro-test-runner
+      test.file="${test.mapred.all.tests.file}"
+      suite.type="mapred"
+      classpath="${test.classpath.id}"
+      test.dir="${test.build.dir}"
+      fileset.dir="${test.src.dir}"/>
+  </target>
 
+
+
   <target name="checkfailure" if="tests.failed">
     <touch file="${test.build.dir}/testsfailed"/>
     <fail unless="continueOnFailure">Tests failed!</fail>

示例如下:

ant run-ut -Dtestcase="org.apache.hadoop.conf.TestJobConf"


运行结束后就可以在${test.build.dir},即build/test看到log文件了。如上面的示例的log文件为:

build/test/TEST-org.apache.hadoop.conf.TestJobConf.txt

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值