检索规则说明:AND代表“并且”;OR代表“或者”;NOT代表“不包含”;(注意必须大写,运算符两边需空一格)
检 索 范 例 :范例一: (K=图书馆学 OR K=情报学) AND A=范并思 范例二:J=计算机应用与软件 AND (U=C++ OR U=Basic) NOT M=Visual
机构地区:[1]东华大学计算机科学与技术学院,上海200051 [2]上海万达信息股份有限公司,上海201112
出 处:《计算机技术与发展》2009年第5期33-36,共4页Computer Technology and Development
基 金:上海市政府电子政务项目(WD-GDRSJ0701)
摘 要:单元测试的出现给程序员的编程工作带来了乐趣,更多的程序员希望能进行深入实践。但在对单元测试更加全面深入的使用过程中,却遇到了越来越多的障碍。随着B/S架构的流行,轻量级容器架构的J2EE模式是大多数项目的首选,并在此基础上使用DAO(数据访问对象)模式与数据库层进行交互。数据库中的数据会在使用过程中变得不稳定,会使得测试代码变得不具可重复性。而单元测试最重要的特性就是可重复性,文中探讨的就是关于DAO层的单元测试的可重复性。经过在实际项目中的认真实践得出了可行的方法,现作简要介绍。DAO层的单元测试的依赖于数据库中的数据,实现单元测试的可重复性需要对于每次单元测试执行时数据库的数据都是符合要求的。可从两方面保证数据库中的数据符合要求:一是启动每轮单元测试时提供符合要求的数据;二是对于那些会破坏数据库状态的单元测试在结束时均执行一个恢复操作,将数据库恢复到原来的状态。Unit testing brings programmer's development fun. So more programmers want to practice it deeply. However, they counter more and more difficulties when they use unit testing deeply. Along with the fashion of B/S architecture,J2EE with lightweight container architecture is the first choice for many projects. And DAO (Data Access Object) pattern is used to communicate with database layer. The data in database will become unstable in the proceas of using the data and therefore makes test code can not become repetitive. But repeatability is the most important feature in unit testing. This paper is about the repeatability of the unit testing on the DAO layer. After the seriously practice of practical project come to a viable way, will describle it completely, here is a briefing. The unit test of DAO layer depends on the data in the database, to achieve repeatability of the unit test requires for the implementation of each time when testing data are in line with the requirements. Can ensure that the data in the database to meet the requirements from two aspects: First, provide data to meet the requirements when start each round of unit test. Second, for those unit test which would undermine the state of database,at the end of the test all execute a resumption of operation, then the database will return to original state.
分 类 号:TP311.5[自动化与计算机技术—计算机软件与理论]
正在载入数据...
正在载入数据...
正在载入数据...
正在载入数据...
正在载入数据...
正在载入数据...
正在载入数据...
正在链接到云南高校图书馆文献保障联盟下载...
云南高校图书馆联盟文献共享服务平台 版权所有©
您的IP:216.73.216.49