Defining the CompanyDao test case
Each CompanyDao
method should have at least one test method defined. We will include exactly one test method per implemented CompanyDao
method. In enterprise applications, we would expect many more scenarios to be covered than the ones identified in the code snippet that follows.
We have also included minimum logging, just enough to split the output when running the test cases. You may wish to add more logging to help analyze the results. The test code assumes that the ttt_company
table has appropriate data. In Chapter 2, The Task Time Tracker Database, we added three rows so that we know there is data available. Additional checks would need to be done if we do not have a database with consistent testing data. The file listing is:
package com.gieman.tttracker.dao; import com.gieman.tttracker.domain.Company; import java.util.List; import static org.junit.Assert.assertTrue; import org.junit.Test; public class CompanyDaoTest extends AbstractDaoForTesting {...