数据迁移中的数据测试

  

很久没有写自己的博客了。自动化测试项目结束后,又参加了一些新项目,有些和测试自动化无关。目前做的是数据迁移测试,即把一个老系统的业务数据,迁移到新系统中。大部分测试都集中在数据的测试,主要根据BMD测试数据字段的对应关系。测试用例都是用SQL脚本写的。为了调用这些测试用例,也写了一个简单的测试框架,思路如下:

<李>

主要。李sql

这个文件有两部分,

1)生成一个TestResult表,记录每一个测试用例的结果,如:

IF  EXISTS  (SELECT  *,得到sys.objects  WHERE  object_id =, OBJECT_ID (N [dbo] . [TestResult]),以及type 拷贝(N 'U '))   ,DROP  TABLE  [dbo]。[TestResult]   开始   ,CREATE  TABLE  [dbo]。[TestResult] (   ,[ResultId] int 身份(1,1),NOT 空,   ,[TestCaseId] nvarchar (255), NOT 空,   ,[ProcedureName] nvarchar (255), NOT 空,   ,[TestCaseResult] nvarchar (255), NOT 空,,   ,[TestLog] nvarchar (max),空,   ,[ExecutionTimeStamp] datetime  NULL   ,)   ,   ,INSERT  INTO  [dbo]。[TestResult],   ,值   ,   ,,   ,(“c - 301”,“AccountID”,“NOT 运行”,“CURRENT_TIMESTAMP),   ,……   ,结束

2)调用每一个测试用例对应的存储过程。

EXECUTE  C_AccountID

2。每一部分数据都有自己的文件,如Account.sql。在这个文件里,包括了将测试用例自动化的存储过程.Example:

- c - 301 - - - - - - - - - - - - - Start  of  AccountID 过程- - - - - - - - - - - - - - - - - - -   USE  TestDatabase   去   IF  OBJECT_ID  (“dbo.AccountID”,“P”), IS  NOT  NULL    ,,,DROP  PROCEDURE  dbo.AccountID   去      CREATE  PROCEDURE  dbo.AccountID   作为   开始   ,,,,,,,DECLARE  @AccountIDCount  int   ,,,,,,,DECLARE  @DupCount  int   ,,,,,,,DECLARE  @LegalCount  int   ,,,,,,,DECLARE  @Result  nvarchar (10)   ,,,,,,,DECLARE  @Comments  nvarchar (255)/*,才能Test 从而account  id 's  mapping  */,,,,   SET 才能;@AccountIDCount =, 0,,,   SET 才能;@AccountIDCount =, (SELECT  COUNT(*),得到[MasterData], T  LEFT  JOIN  [TargetList], S    ,,,,,,,,,,,,,,,,,,,,,,,,演员(t . [iAccountID]大敌;as  nvarchar),=,,演员(s . [PARTYID]大敌;as  nvarchar), collate  Latin1_General_CI_AS   ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,WHERE  t [iAccountID], IS  NULL )/*,才能Check  there  is  no  duplicate  account  id  */,,,,,,,,,,,,,,,,,,,,,,,,,,,,   SET 才能;@DupCount =, 0,,,   SET 才能;@DupCount =, (SELECT  COUNT(*),得到,[MasterData], WHERE  (iAccountID 拷贝(SELECT  iAccountID 得到[MasterData], group  by  iAccountID  having  COUNT(*)在1),))   ,,   ,/* check 从而account  id  is  10, digits  */,   ,SET  @LegalCount =, (SELECT  *,得到[Rex_DCL5_LDS_Customer_STG_MasterData], WHERE  iAccountID  not  like  % 0000000000%)   ,   ,,,,,,,IF  @AccountIDCount  +, @DupCount  +, @LegalCount=0   ,,,,,,,开始   ,,,,,,,,,,,,,,,SET  @Result =,“通过”   ,,,,,,,,,,,,,,,SET  @Comments =,“[iAccountID],断开连接;正确的。,   ,,,,,,,结束   ,,,,,   ,,,,,,,   ,,,,,,,开始   ,,,,,,,,,,,,,,,SET  @Result =,“失败”   ,,,,,,,,,,,,,,,SET  @Comments =,“时间是:There ”, +,演员(@AccountIDCount  as  nvarchar), +,“records  of  T  data 断开连接;not  contained 拷贝S 数据。’+,   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null

数据迁移中的数据测试