如何在UI测试运行之前和之后设置和清理我的数据库 [英] How to setup and cleanup my Database before and after the UI tests run

查看:85
本文介绍了如何在UI测试运行之前和之后设置和清理我的数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

Hello,

 

我正在尝试自动化ui测试我的Silverlight应用程序。我需要在运行测试时设置并清除我的Oracle数据库。

I am trying to automate ui tests on my Silverlight App. I need to setup and clear my Oracle Database when I run the tests.

我创建了一个脚本:"setup.sql"我定义了我想要执行的查询。我在Localsettings配置的部署选项卡上添加此文件。

I've created a script: "setup.sql" where I define the the query that I want to execute. I add this file on the Deployment Tab on Localsettings configurations.

 

setup.sql

setup.sql

 

CREATE TABLE HSDEV.TESTE_MARIA1

CREATE TABLE HSDEV.TESTE_MARIA1

Id_test int,

Id_test int,

LastName varchar(255),

LastName varchar(255),

FirstName varchar(255))

FirstName varchar(255))

 

 

然后,我创建了一个.bat文件,我在部署选项卡com Localsettings配置中添加了这个文件,我在Setup和Cleanup Scripts上选择了这个路径。

Then, I created a .bat file and I add this file on Deployment tab com Localsettings configurations and I choose this path on Setup and Cleanup Scripts.

 

setup.bat

setup.bat

sqlcmd -S COMPUTERNAME -i setup.sql

sqlcmd -S COMPUTERNAME -i setup.sql

 

这两个文件都在解决方案文件夹中。

Both files are in solution folder.

然后,我创建了一个简单的Web测试,然后运行它。测试通过但表格没有在我的数据库上创建。

Then, I create a simple web test and I ran it. The test pass but the table wasn't create on my Database.

 

我在做什么错误?我错过了什么吗?

What am I doing wrong? Am I missing something?

 

谢谢。

 

祝你好运,

Maria Lisboa

Maria Lisboa

推荐答案

您好,

如果您使用编码UI测试或单元测试来自动化UI,那么您可以使用  [ TestInitialize]& [TestCleanup] 属于在UI测试之后分别在UI测试之前执行的方法的属性。

In case you are using Coded UI Test or Unit Test for automating UI, then you can use [TestInitialize] & [TestCleanup] attributes above methods to execute before UI Test & after UI Test respectively.

Ex:

[TestInitialize]public void TestInitialize(){   //Include your code for setting up database}[TestCleanup]public void TestCleanup(){   //Include your code for cleaning up database}

谢谢

Vijet


这篇关于如何在UI测试运行之前和之后设置和清理我的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆