是否有与使用的TestCase和Microsoft测试管理器.testsettings文件的方法吗? [英] Is there an alternative for using a .testsettings file with TestCases and Microsoft Test Manager?

查看:519
本文介绍了是否有与使用的TestCase和Microsoft测试管理器.testsettings文件的方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个特殊情况在这里是造成我们的自动化测试失败在新创建的实验室环境中,使用TFS 2012。

We have a peculiar situation here that is causing our automated tests to fail on a newly created lab environment, using TFS 2012.

我们一直有一帮上考验我们的DAL code,这反过来又使用了<一个单位测试href=\"http://msdn.microsoft.com/en-us/library/microsoft.practices.enterpriselibrary.data%28v=pandp.31%29.aspx\"相对=nofollow>企业库数据应用程序块来对数据库进行操作​​。这是设置好几年前,为了使我们的客户选择使用SqlServer使用Oracle数据库我们的产品旁边,趁着<一个href=\"http://msdn.microsoft.com/en-us/library/microsoft.practices.enterpriselibrary.data.databasefactory%28v=pandp.31%29.aspx\"相对=nofollow> DatabaseFactory 类和所有支持通用接口和类在entlib.data。我提到的单位是这样,因为这些其实并不是纯粹的单元测试,但整合的人,因为他们需要一个真正的数据库工作有看头。

We've always had a bunch of 'unit' tests that tested our DAL code, which in turn uses the Enterprise Library Data Application Block to perform operations on the database. This was setup quite a few years ago, to enable our clients to choose either SqlServer or Oracle databases alongside our product, taking advantage of the DatabaseFactory class and all the supporting generic interfaces and classes in the entlib.data. I mentioned 'unit' like this because these are actually not pure unit tests but integration ones, seeing as they require a real database to work.

要测试对两个数据库相同的SQL code,我们保持'资源'文件夹内的两个独立的.config文件在我们的TFS项目的分支,指向我们的测试数据库:

To test the same SQL code against both databases, we maintain two separate .config files inside a 'Resources' folder in our TFS project branch, pointing to our test databases:


  • 资源\\ SqlServer的\\ ConnectionStrings.config (SqlServer的特定连接字符串)

  • 资源\\ ORACLE \\ ConnectionStrings.config (Oracle专用的连接字符串)

  • Resources\SqlServer\ConnectionStrings.config (SqlServer specific connection strings)
  • Resources\Oracle\ConnectionStrings.config (Oracle specific connection strings)

在根资源文件夹中,有两个所附.testsettings文件,负责部署特定文件每个数据库:

In the root Resources folder, there are two accompanying .testsettings files, responsible for deploying files specific to each database:


  • 资源\\ SqlServer.testsettings (其中部署的SqlServer \\ ConnectionStrings.config文件)

  • 资源\\ Oracle.testsettings (其中部署在Oracle \\ ConnectionStrings.config文件)

  • Resources\SqlServer.testsettings (which deploys the SqlServer\ConnectionStrings.config file)
  • Resources\Oracle.testsettings (which deploys the Oracle\ConnectionStrings.config file)

由于整个结构是源头控制,在testsettings是能够通过使用相对路径,允许我们无需手动设置参数测试一切找到.config文件。
在开发者的机器,我们始终运行测试时选择 SqlServer.testsettings 文件,使他们不需要安装前检查,以验证其改变了整个Oracle环境在code。验证的甲骨文身边总是发生在我们的构建过程中,我们实际测试的每一个方法两次:第一次使用相同的 SqlServer.testsettings 由开发人员使用,再使用 Oracle.testsettings

Since the whole structure is in source control, the testsettings is able to find the .config files by using relative paths, allowing us to test everything without having to setup parameters manually. On devs machines, we always select the SqlServer.testsettings file when running the tests, so that they don't need to have the whole oracle environment installed to validate their changes before checking in the code. The Oracle side of the validation always occurred in our build process, where we actually test every method twice: first using the same SqlServer.testsettings used by the developers, and then using the Oracle.testsettings.

这个方法,我们可以设置我们的测试程序集app.configs的是connectionStrings节点重定向到一个外部文件,如下所示:

This way, we can setup our test assemblies' app.configs to redirect the connectionStrings node to an external file, like this:

<configuration>
  <connectionStrings configSource="ConnectionStrings.config"/>
  ...

在测试运行,MSTest的拷贝适当ConnectionStrings.config文件添加到测试的工作文件夹,在此基础上.testsettings被用于启动运行

When the tests are run, mstest copies the adequate ConnectionStrings.config file to the test's working folder, based on which .testsettings was used to initiate the run.

这是工作的罚款直到今天,当我发现<一个href=\"http://social.msdn.microsoft.com/Forums/vstudio/en-US/229fe0b3-5ebc-4e7e-9cd5-c63bbf1f7052/additional-deployment-items-for-automated-$c$cdui-test-started-from-microsoft-test-manager\"相对=nofollow>测试开始通过微软测试管理器忽略在Visual Studio .testsettings文件。现在我试图运行在我们的实验室环境中,这些相同的测试,但ConnectionStrings.config文件不会被部署(可以理解)和测试失败。

This was working fine until today, when I discovered that tests started through Microsoft Test Manager ignore the Visual Studio .testsettings files. Now I'm trying to run these same tests in our lab environment but the ConnectionStrings.config files are not deployed (understandably) and the tests fail.

我们如何能够在不使用.testsettings文件实现这一目标?有巨大的头痛在我们的新的x64构建服务器试图安装oracle的正确后,我们在构建定义禁用甲骨文的测试。现在,我们开始建立我们的实验室环境中,我们认为大鱼大肉使用Oracle我们的整个系统,使我们能够再次运行这些单元测试与Oracle特定的连接字符串来验证我们的查询配置在它的机器之一。同时,我们要保持本地测试一切,并使用SqlServer的构建服务器上也。

How can we achieve this without using .testsettings files? After having huge headaches trying to setup oracle correctly in our new x64 build server, we disabled Oracle tests in the build definition. Now that we started setting up our lab environment, we thought about having one of the machines in it configured with our whole system using Oracle, enabling us to again run these 'unit tests' with oracle-specific connection strings to validate our queries. At the same time, we want to keep testing everything locally and on the build server using SqlServer also.

我想使用<一个href=\"http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.deploymentitemattribute%28v=vs.80%29.aspx\"相对=nofollow> [DeploymentItem] 在这种情况下是不可能的,因为它是为静态文件和不可选的,动态的像我们的当前设置。

I think using [DeploymentItem] in this case is impossible, since it is meant for static files and not selectable, dynamic ones like our current setup.

是否有任何相当于我们可以与MTM /实验室里面的信封的TestCase使用.testsettings部署过程?在我们的测试计划的属性标签,我可以看到自动运行 - &GT;测试设置选项,但似乎只通过指定的绝对路径(这实际上将在目标计算机上解决),以允许部署。有没有有指定相对路径,指向我们的ConnectionStrings.config文件上签TFS的方式?也许另一种选择存在我的思念,也许是使用多个构建配置?

Is there any equivalent to the .testsettings deployment process that we could use with TestCases inside MTM/Lab Env? On the Properties tab for our TestPlan, I can see the Automated Runs -> Test Settings option, but that only seems to allow deployment by specifying absolute paths (which will actually be resolved on the target machines). Is there a way to specify a relative path there, pointing to our ConnectionStrings.config files checked in on TFS? Maybe yet another alternative exists that I'm missing, perhaps using multiple build configurations?

推荐答案

通过进入创建为每个服务器类型的单独构建配置的配置管理器的,点击的的下的活动的解决方案配置的。编辑项目文件和做这样的事情:

Create separate build configurations for each of the server types by going into Configuration Manager and click New under Active solution configurations. Edit the project file and do something like this:

<PropertyGroup Condition="'$(Configuration)' == 'Oracle'">
  <appConfig>App.Oracle.Config</AppConfig>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'SQL'">
  <appConfig>App.SQL.Config</AppConfig>
</PropertyGroup>

然后确保你有正确的连接字符串中的每个配置文件。然后,您可以配置TFS使用这些构建配置来构建。

Then ensure you have the correct connection strings in each of the config files. You can then configure TFS to build using those build configurations.

使用的PropertyGroup和条件更多信息,的 MSBuild的配置和的 MSBuild项目性质

More info on using PropertyGroup and Condition, MSBuild Configurations and MSBuild project properties

这篇关于是否有与使用的TestCase和Microsoft测试管理器.testsettings文件的方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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