数据库重构与数据库单元测试

提起代码重构和单元测试,相信大家都不陌生,重构和单元测试也成为了大家开发中必不可少的一部分,但是您知道数据库重构(Database Refactoring)吗?您知道数据库单元测试(Database Unit Testing)吗?看看SachinRe是怎么说的。


1
.数据库重构(Database Refactoring

在《What is database refactoring?》这篇文章中,SachinReDatabase Refactoring作了如下解释:

Database refactoring is merely extending this concept of refactoring from the application code to your database code. Much in the same way, you can imagine a database rename refactoring would rename a database object and all of its references in the database. Similarly, an extract stored procedure refactoring would pull out a SQL fragment from a stored procedure and place it in its own reusable procedure.


2
.数据库单元测试(Database Unit Testing

在《What is database unit testing?》文章中,SachinReDatabase Unit Testing的解释:

How does this all relate to database development? The direct analog of application unit tests in the database world are tests of a database’s programmability objects. These include, for example, a database’s stored procedures, functions, and triggers.

并且举了一个简单的存储过程单元测试的例子:

DECLARE @CustomerId nchar(5)

SELECT @CustomerId = 'EASTC'

EXEC dbo.CustOrderHist @CustomerId
 

IF (@@ROWCOUNT <> 19)

RAISERROR('Actual Rowcount not equal to expected 19',1,1)

感兴趣的朋友不妨阅读一下上面两篇文章

作者:TerryLee
出处:http://terrylee.cnblogs.com
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
posted @ 2006-07-02 11:29 TerryLee 阅读(3545) 评论(4)  编辑 收藏 网摘 所属分类: [21]  数据库相关[14]  测试与重构

  回复  引用    
#1楼 2006-07-02 16:56 | 3322 [未注册用户]
第一次听说哦:D
  回复  引用  查看    
#2楼 [楼主]2006-07-03 11:13 | TerryLee      
@3322
^_^
  回复  引用  查看    
#3楼 2006-07-03 11:54 | kid_li      
哈哈,厉害,TerryLee,将重构和单元测试进行到底(层)
  回复  引用  查看    
#4楼 [楼主]2006-07-03 16:24 | TerryLee      
@kid_li

呵呵,其实是SachinRe厉害才对:-)




标题  
姓名  
主页
Email (博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
该文被作者在 2006-10-21 13:15 编辑过
Google站内搜索

相关文章:

相关链接: