1. 程式人生 > >Junit4測試報錯

Junit4測試報錯

1、字串陣列越界

  java.lang.String IndexOutOfBounds Exception:String index out of range:-1

  導致:

   Transaction rolled back because it has been marked as rollback-only.

分析原因:

    String[] params = new String[2];

    params[0] = date;

    params[1] = code;

    int num = getSql(sb.toString(),params);

2、資料傳輸異常

    java.lang.AssertionError:expected:<5> but was :<12>

3、比較失敗異常

    org.junit.ComparisonFailure:expected : <2014022[1]> but was :<2014022[0]