你的是junit test吗?
如果是的话,可以看一下帮助文件,有界面的有command方式的。

解决方案 »

  1.   

    这个是程序import java.text.DecimalFormat;public class Time1 extends Object {
    private int hour;
    private int minute;
    private int second;

    public Time1() {
    setTime( 0,0,0 );
    }

    public void setTime (int h,int m ,int s) {
    hour = (( h>=0 && h<24) ? h:0);
    minute = (( m>=0 && m<60) ? m:0);
    second = (( s>=0 && s<60) ? s:0);
    }

    public String toUniversalString() {
    DecimalFormat twoDigits = new DecimalFormat("00");

    return twoDigits.format(hour) + ":" +
       twoDigits.format(minute) + ":" +
       twoDigits.format(second) ;
        }

    public String toString () {
    DecimalFormat twoDigits = new DecimalFormat("00");

    return ((hour == 12 || hour == 0) ? 12:hour%12 ) + ":" +
       twoDigits.format(minute) + ":" +
       twoDigits.format(second) + (hour < 12  ? "AM":"PM");
        
    }
    }

    这个是测试程序import javax.swing.JOptionPane;public class TimeTest1 {
    public void main ( String args[] ) {
    Time1 time = new Time1();

    String output = "The initial universaltime is:"+
    time.toUniversalString()+
    "\n The initial Standard time is : " + time.toString() +
    "\n Implicit toString() call:"+ time;

    time.setTime( 13,27,6);
    output += "\n \n Universal time after setTime is:" +
    time.toUniversalString()+
    "\n Standard time after set timeis:" + time.toString();

    time.setTime(99,99,99);
    output+="\n After attemping invalid settings:" +
    "\n Universal time:"+ time.toUniversalString()+
    "\n Standard time:" + time.toString();

    JOptionPane.showMessageDialog( null,output,"Testing Class Time1",
      JOptionPane.INFORMATION_MESSAGE);

    System.exit(0);

    }
    }
      

  2.   

    public void main ( String args[] ) {
    是不是应该加上 static????
      

  3.   

    public static void main(String[] args)extends Object有点多余,
    其次建议直接将main()放到要测试的class里(或多个里的主要一个)去
    这样可以直接
    java XXX 测试 XXX
      

  4.   

    噢…………
    是我漏掉了static,扇自己一个耳光先。谢谢两位了!