在eclipse中操纵Ant实施JUnit[Java编程]
本文“在eclipse中操纵Ant实施JUnit[Java编程]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
成立工程:
在eclipse中成立一个java project.
AntTest
配置:
-src
-com.test
-ABS.java
-ABSTest.java (Junit Test Case)
-lib
-build.xml
-JUNIT_HOME/junit.jar
eclipse->window->preference->ANT->Runtime->Classpath->ANT Home Entry
挑选Add External JAR,加入ECLIPSE_HOME/plugins/org.junit.../junit.jar
build.xml的内容:
1
运行:
2 <? xml version="1.0" ?>
3 < project name ="project" default ="junit" >
4 < property name ="run.classpath" value ="bin" ></ property >
5 < property name ="run.srcpath" value ="src" ></ property >
6 < property name ="test.srcpath" value ="src" ></ property >
7 < property name ="test.report" value ="report" ></ property >
8 < property name ="lib.dir" value ="lib" />
9 < path id ="compile.path" >
10 < fileset dir ="${lib.dir}" >
11 < include name ="**/*.jar" />
12 </ fileset >
13 </ path >
14 < target name ="compile" >
15 < javac destdir ="${run.classpath}" srcdir ="${run.srcpath}" classpathref ="compile.path" />
16 < javac destdir ="${run.classpath}" srcdir ="${test.srcpath}" classpathref ="compile.path" />
17 </ target >
18 < target name ="junit" depends ="compile" >
19 < tstamp />
20 < mkdir dir ="${test.report}" />
21 < mkdir dir ="${test.report}/framework-${DSTAMP}-${TSTAMP}" />
22 < junit printsummary ="true" >
23 < classpath >
24 < pathelement path ="${run.classpath}" />
25 < fileset dir ="${lib.dir}" >
26 < include name ="**/*.jar" />
27 </ fileset >
28 </ classpath >
29 < formatter type ="plain" />
30 < batchtest fork ="yes" todir ="${test.report}/framework-${DSTAMP}-${TSTAMP}" >
31 < fileset dir ="${test.srcpath}" >
32 < include name ="**/*Test.java" />
33 </ fileset >
34 </ batchtest >
35 </ junit >
36 </ target >
37 </ project >
右键build.xml->run as "Ant Build".
后果:
掌握台有输出后果,比方:
Buildfile: C:Documents and SettingsqianwangMy DocumentsDSMPWorkspaceAntTestbuild.xml
同时,AntTest/report(假如没有自动成立的目录)中,产生.txt格局的文本文件.
compile:
junit:
[mkdir] Created dir: C:Documents and SettingsqianwangMy DocumentsDSMPWorkspaceAntTestreportframework-20070201-1712
[junit] Running com.test.ABSTest
[junit] Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 0 sec
BUILD SUCCESSFUL
Total time: 19 seconds
后果文件中,会指出运行了哪些testcase(指出被测试的办法名test**).
假若有failures/errors,非常的具体信息也会输出在这里.
以上是“在eclipse中操纵Ant实施JUnit[Java编程]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |