帮助编写JUnit for JDBC [英] Help writing JUnit for JDBC

查看:71
本文介绍了帮助编写JUnit for JDBC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个类,在其中我将值插入到SQL中,如下所示:

I created one class,in which i am inserting values into SQL as follows:

  public class ABC{
     some code here..........
   ...............
    public void insertUsers(String firstName,String lastName,String location){
      pre.setString(1,firstName);

我为此课程创建了测试课程.

I created test class for this class.

我想使用assert语句为此方法insertUsers()编写测试用例. 如何为上述方法编写断言语句.

I want to write test case for this method insertUsers(),using assert statement. how to write assert statement for above method.

推荐答案

我不会测试数据到数据库的插入,实际上在单元测试期间它不能访问数据库,这可以通过自动功能GUI测试工具来解决.您的应用程序.

I wouldnt test the insertion of the data to the database, actually its not performant to access database during unittesting, this can be covered threw automated functional GUI testing tools of your application.

您可能要测试的是预期查询的生成,这可以实现,如果您将语句的执行和执行分开,则可以比较生成的语句与预期的语句,而无需访问数据库最团结的

what you may want to test is the generation of the expected queries, this can realised if you seperate the geenration and the execution of the statements, you will be able to compare generated statements with expected ones without having to access you database from the unitest.

这篇关于帮助编写JUnit for JDBC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆