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

          常用鏈接

          留言簿(12)

          隨筆分類(lèi)

          隨筆檔案

          groovy

          搜索

          •  

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          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 大衛(wèi) 閱讀(435) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): Java
          主站蜘蛛池模板: 金寨县| 瑞昌市| 海伦市| 河南省| 葫芦岛市| 桑植县| 旺苍县| 隆昌县| 吉水县| 北碚区| 铜陵市| 广南县| 奎屯市| 阜宁县| 那坡县| 台北县| 英吉沙县| 睢宁县| 汤原县| 上杭县| 罗源县| 溧阳市| 布尔津县| 壶关县| 开原市| 宝清县| 兴和县| 手机| 谢通门县| 神农架林区| 共和县| 罗田县| 东光县| 镇安县| 阜阳市| 南漳县| 高陵县| 阿坝| 永春县| 宜黄县| 屏山县|