SQL存储过程测试(8)——示例程序

发表于:2009-11-18 15:24

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:igoone    来源:51Testing软件测试博客

#
SQL
分享:

  此部分内容创建一个轻量级T-SQL测试套件,总共有3个脚本。

  用于创建测试平台数据和待测存储过程的脚本:

--======================
--makeDbTestAndResults.sql

use master
go

if exists (select * from sysdatabases where name = 'DbTestAndResults')
 drop database makeDbTestAndResults
go

if exists (select * from sysxlogins where name = 'testLogin')
 exec sp_droplogin 'testLogin'
go

create database makeDbTestAndResults
go

use makeDbTestAndResults
go

create table tb1TestCases
(
 caseID char(4) primary key,
 input datetime not null,
 expectedChecksum int not null
)
go

--下面插入的是用于usp_HiredAfter的测试数据,采用了对期望值求校验和的方法
--也可以通过BCP,BTS或者C#程序从文本文件读入这些数据

insert into tb1TestCases values('0001','10/25/2009',1042032)
insert into tb1TestCases values('0002','10/25/2009',9999999)--deliberate error
insert into tb1TestCases values('0003','10/25/2008',25527856)
insert into tb1TestCases values('0004','10/10/2006',1042032)
go

create table tb1Results
(
 caseID char(4) not null,
 result char(4) not null,
 whenRun datetime not null
)
go

exec sp_addlogin 'testLogin','secret'
go

exec sp_grantdbaccess 'testLogin'
go

grant select,insert,delete,update on tb1TestCases to testLogin
go

grant select,insert,delete,update on tb1Results to testLogin
go

--结束脚本

31/3123>
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号