Posted By:
Joseph_Hobbs
Posted On:
Monday, February 4, 2008 10:47 AM
Does anyone have any recommendations on how they arrange/group their jUnit tests? Should there be one large 'test' for each method, one small 'test' for each method possibility, etc? So, as an example... Assume the following method: int ReportManager.createReport(Report report) In this case, I'd want to test for the following: Does it throw an exception if report == null ? Does it throw an exception if report == empty ? Does it throw an exception if report is duplicate? Does it return valid ID if successful? So given those 4 possibilities, how would you do it? Would you create a single test method (testCr
More>>
Does anyone have any recommendations on how they arrange/group their jUnit tests? Should there be one large 'test' for each method, one small 'test' for each method possibility, etc?
So, as an example... Assume the following method:
int ReportManager.createReport(Report report)
In this case, I'd want to test for the following:
-
Does it throw an exception if
report == null
?
-
Does it throw an exception if
report == empty
?
- Does it throw an exception if report is duplicate?
- Does it return valid ID if successful?
So given those 4 possibilities, how would you do it? Would you create a single test method (testCreateReport) that tests all 4? Or would you create four separate test methods (testCreateReportNull, testCreateReportEmpty, testCreateReportDuplicate, TestCreateReportSuccess)?
Thanks!
<<Less