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

提起代码重构和单元测试,相信大家都不陌生,重构和单元测试也成为了大家开发中必不可少的一部分,但是您知道数据库重构(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.

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

None.gif DECLARE   @CustomerId   nchar ( 5 )
None.gif
None.gif
SELECT   @CustomerId   =   ' EASTC '
None.gif
None.gif
EXEC  dbo.CustOrderHist  @CustomerId
None.gif 
None.gif
None.gif
IF  ( @@ROWCOUNT   <>   19 )
None.gif
None.gif
RAISERROR ( ' Actual Rowcount not equal to expected 19 ' , 1 , 1 )

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值