隨筆 - 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 大衛 閱讀(436) 評論(0)  編輯  收藏 所屬分類: Java
          主站蜘蛛池模板: 金乡县| 察雅县| 峨山| 濮阳县| 鄂伦春自治旗| 遵义市| 从化市| 龙游县| 巴南区| 台东县| 遂昌县| 宣化县| 靖江市| 阿拉善右旗| 册亨县| 达州市| 洮南市| 通化县| 昌图县| 延长县| 娱乐| 南澳县| 康平县| 成都市| 海林市| 三门县| 新平| 临澧县| 彰化市| 彭泽县| 晋城| 如皋市| 惠来县| 吉隆县| 隆化县| 公主岭市| 安岳县| 连平县| 浦北县| 上林县| 资中县|