1

需要编写 junit 来检查以下返回文件列表的方法。

     public List<pdffiles> noticesPerform (Account account, fromDate, ToDate)
       {
         List<pdffiles> notices = new Arraylist();
            ............
            ..
         return notices;
       }

如何在junit签入

  1. 如何检查返回列表不为空?是否需要使用asserThat之类的?有没有最好的方法呢?

  2. 如何通过测试对象account,fromDate,Todate来测试方法?

4

2 回答 2

0

使用 AssertNull() 方法检查空值。创建对象,或模拟它们(如果您决定采用模拟方法,您可以创建初始化这些参数对象的方法,然后您可以通过为它们的创建提供替代方法来模拟这些对象。)

于 2012-12-27T05:07:08.270 回答
0

使用fest assert 2.0 然后你可以这样做:

XXX returnedList = noticesPerform (...)
assertThat(returnedList).containsOnly(A, B, C);
于 2012-12-28T16:14:07.783 回答