0

我需要使用测试用例在方法中打印值。我的代码是:

public void testgetAllRatingElementsWeekNo() throws Exception
{
    String METHOD_NAME = "testgetAllRatingElementsWeekNo";
    log.entering(CLASS_NAME, METHOD_NAME);

    populateForTestMethodValues("1");
    populateWeekOfList();
    int allRatingElementsWeekNo = weeklyDlvyInstancesDashboardReportForm.getAllRatingElementsWeekNo();
    System.out.println("allRatingElementsWeekNo :" + allRatingElementsWeekNo );
    assertEquals("testgetAllRatingElementsWeekNo is Not Greater than Zero: ", allRatingElementsWeekNo > 0, allRatingElementsWeekNo);

    log.exiting(CLASS_NAME, METHOD_NAME);
}

我需要在抛出异常之前打印我的值。

4

1 回答 1

0

您可以添加尝试并最终阻止,最后您可以打印消息。我不知道这是否可以做得比这更好:

public void testgetAllRatingElementsWeekNo() throws Exception
{
try {
    String METHOD_NAME = "testgetAllRatingElementsWeekNo";
    log.entering(CLASS_NAME, METHOD_NAME);

    populateForTestMethodValues("1");
    populateWeekOfList();
    int allRatingElementsWeekNo = weeklyDlvyInstancesDashboardReportForm.getAllRatingElementsWeekNo();
    System.out.println("allRatingElementsWeekNo :" + allRatingElementsWeekNo );
    assertEquals("testgetAllRatingElementsWeekNo is Not Greater than Zero: ", allRatingElementsWeekNo > 0, allRatingElementsWeekNo);
} finally {
    log.exiting(CLASS_NAME, METHOD_NAME);
}
}
于 2013-01-01T10:17:41.770 回答