随笔 - 55  文章 - 187  trackbacks - 0
<2008年6月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

常用链接

留言簿(12)

随笔分类

随笔档案

groovy

搜索

  •  

最新评论

阅读排行榜

评论排行榜

build.xml
 1<?xml version="1.0"?>
 2<project name="anttest" default="run">
 3    <property name="build.path" value="build/classes/"/> 
 4    <path id="compile.classpath">
 5        <fileset dir="lib">
 6            <include name="*.jar"/>
 7        </fileset>
 8    </path>
 9
10    <target name="init">
11        <mkdir dir="${build.path}" />
12        <mkdir dir="dist" />
13    </target>
14    <target name="compile" depends="init">
15        <javac srcdir="src/" destdir="${build.path}" classpath="${build.path}">
16            <classpath refid="compile.classpath"/>
17        </javac>
18        <echo>compilation complete!</echo>
19    </target>
20    <target name="run" depends="compile">
21        <java classname="org.test.work.HelloWorld" classpath="${build.path}" />
22        <echo>Run complete!</echo>
23    </target>
24
25    <target name="test" depends="compile">
26        <junit printsummary="on" haltonfailure="true" showoutput="true">
27            <classpath refid="compile.classpath"/>
28            <classpath path="${build.path}"/>
29            <formatter type="xml" />
30            <test name="org.test.work.HelloWorldTest"/>
31        </junit>
32    </target>
33    
34</project>

HelloWorld.java
 1package org.test.work;
 2
 3public class HelloWorld{
 4
 5    public String showMessage(){
 6        return "Hello world!!!";
 7    }

 8
 9    public static void main(String[] args){
10 
11        System.out.println("Hello world!!!");
12    }

13}


HelloWorldTest.java
 1package org.test.work;
 2
 3import static org.junit.Assert.*;
 4import org.junit.*;
 5
 6import org.test.work.HelloWorld;
 7
 8public class HelloWorldTest{
 9
10    private static HelloWorld hw = null;
11
12    @BeforeClass
13    public static void setUp(){
14        hw = new HelloWorld();
15    }

16
17    @Test
18    public void showHelloWorld(){
19        assertEquals(hw.showMessage(),"Hello world!!!");
20    }

21
22    @AfterClass
23    public static void tearDown(){
24        hw = null;
25    }

26
27}
posted on 2008-06-09 20:24 大卫 阅读(416) 评论(0)  编辑  收藏 所属分类: Java

只有注册用户登录后才能发表评论。


网站导航: