基于模型生成自动化测试用例

发表于:2010-5-17 15:29

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

 作者:爱你小钟(chinabyte)    来源:51Testing软件测试网采编

  而Login_Start这个函数就有点复杂了,因为在模型里面,Login_Start这个动作要求两个参数,或者说是状态—用户名和密码。而且用户分为Administrator和Authenticated两类,密码也类似。那么在哪个地方将这些抽象的状态具体化呢?当然是在执行测试用例之前,要么是构造函数,要么是前文说到的 Initialize函数。我的例子里面是在构造函数里执行初始化操作:

  public string wrongPassword;
  public Dictionary modelUserToRealUser;
  public Dictionary realUserPassword;
  public Site()
  {
  modelUserToRealUser = new Dictionary();
  modelUserToRealUser.Add(”Anonymous”, TestLibrary.Consts.ContributorUser);
  modelUserToRealUser.Add(”Authenticated”, TestLibrary.Consts.ModeratorUser);
  modelUserToRealUser.Add(”Author”, TestLibrary.Consts.AuthorUser);
  modelUserToRealUser.Add(”Administrator”, TestLibrary.Consts.AdminUserName);
  realUserPassword = new Dictionary();
  realUserPassword.Add(TestLibrary.Consts.AdminUserName, TestLibrary.Consts.CommonPassword);
  realUserPassword.Add(TestLibrary.Consts.AuthorUser, TestLibrary.Consts.CommonPassword);
  realUserPassword.Add(TestLibrary.Consts.ContributorUser, TestLibrary.Consts.CommonPassword);
  realUserPassword.Add(TestLibrary.Consts.ModeratorUser, TestLibrary.Consts.CommonPassword);
  wrongPassword = “abcefghi”;
  }

  将所有抽象出来的动作和状态具体化以后,就可以让 NModel产生测试用例并根据我们提供的信息自动执行测试用例了,下面这个命令完成这个操作:

  Ct.exe /r:TrainStep.dll /r:TrainMode.dll /iut:Train.Test.Site.Create TrainMode.WebSiteModel.CreateLoginModel

  Ct.exe用来产生并执行测试用例,为了完成这个工作,ct.exe需要知道模型(TrainModel.dll中的 TrainModel.WebSiteModel.CreateLoginModel)和模型的一个实例(TrainStep.dll),但是/iut这个参数是干什么用的?因为一个dll文件当中,你可以有模型的多个实例,或者不同模型的实例,因此,ct.exe需要你明确指定创建模型实例的方法(Train.Test.Site.Create)。

33/3<123
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

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

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

沪ICP备05003035号

沪公网安备 31010102002173号