0

How to write test cases for the class below. It checks for values of the given query in a database.

public class DboQueryCheck {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        System.out.println("Start DboDaoService");
        DboDaoService dboDaoServcice = new DboDaoService();
        dboDaoServcice.build();
        String query = " select o.org_name,  l.organization_id from " +
                       " code_value cv,code_value cv_loc,code_value_outbound cvo,location l,organization o" +
                       " where " + 
                       " (cv.cdf_meaning = 'INGENI' or cv.cdf_meaning = 'MEDNEC')" +
                       " and cvo.contributor_source_cd = cv.code_value" +
                       " and cvo.alias_type_meaning = 'FACILITY'" +
                       " and l.location_cd = cvo.code_value" +
                       " and cv_loc.code_value = l.location_cd" + 
                       " and cv_loc.code_set = 220" +
                       " and o.organization_id = l.organization_id" + 
                       " order by o.org_name, cv_loc.display, cv.cdf_meaning";


        System.out.println();
        dboDaoServcice.report(query);

    }
}
4

1 回答 1

2

你没有。在您的示例中,您测试的不仅仅是一个单元。因此,根据定义,您不能对此进行“单元”测试。如果您想对此进行测试,至少考虑使用DBUnit或内存数据库,如H2 / HSQLDB数据库。

或者,您可以测试生成的 SQL 命令,但我想知道它的值是什么。

于 2013-06-27T19:30:01.447 回答