1. 程式人生 > >小學生算術測試代碼

小學生算術測試代碼

str 作業 繼續 ima false ring 學生 http ()

好難啊

211606361 何承華
211606377覃一霸

一.單元測試

1.需使用junit插件寫測試代碼

二.代碼

@Test//測試傳入的參數是否正確
public void test() {
    String[] str = {"-grade","3","n","10"};
    assertEquals(true ,MathExam6361.jibu(str)); 
}   
     @Test//測試傳入的年級超過範圍是否正確
      public void test1() {
          String[] str = {"-grade","0","n","10"};
          assertEquals(false ,MathExam6361.jibu(str));         
   }
       @Test//測試傳入的題數超過範圍是否正確
         public void test2() {
            String[] str = {"-grade","3","n","101"};
          assertEquals(false ,MathExam6361.jibu(str));         
   }
          @Test//測試傳入的參數超過範圍是否正確
               public void test3() {
              String[] str = {"-grade","0","n","101"};
                assertEquals(false ,MathExam6361.jibu(str));       
   }
         @Test//測試傳入的參數為負數是是否正確
           public void test4() {
                 String[] str= {"-grade","-1","n","-10"};
            assertEquals(false ,MathExam6361.jibu(str));
   }
            @Test//測試傳入的年級為小數是否正確
         public void test5() {
    String[] str = {"-grade","3.0","n","10"};
    assertEquals(true ,MathExam6361.jibu(str)); 
    }

}

三.類圖

技術分享圖片

四、總結

這是這次作業目前的進度,接下來我會在國慶繼續寫完

小學生算術測試代碼