隨筆 - 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 大衛 閱讀(431) 評論(0)  編輯  收藏 所屬分類: Java
          主站蜘蛛池模板: 和平区| 明水县| 屯留县| 开鲁县| 安溪县| 郁南县| 手游| 迭部县| 隆昌县| 博罗县| 修武县| 本溪市| 凯里市| 临沭县| 称多县| 古田县| 哈巴河县| 枝江市| 方正县| 乌兰察布市| 南丰县| 措勤县| 新巴尔虎右旗| 温宿县| 锡林浩特市| 什邡市| 静海县| 宿松县| 郯城县| 龙州县| 柳江县| 平果县| 黑水县| 开平市| 丘北县| 湘阴县| 顺昌县| 门源| 丰都县| 锡林郭勒盟| 焉耆|