vs 2010高级版/最终版中的自定义测试条件 [英] Custom test condtions in vs 2010 premium/ultimate
问题描述
在阅读以下文章后 在msdn上为数据库单元测试设计器创建测试条件 ,我决定尝试为数据库单元测试创建自定义测试条件
After reading the following article Create Test Conditions for the Database Unit Test Designer on msdn i decided to try create a custom testcondition for my database unit tests
- 我已经满足了Ultimate或Premium的要求.
- 创建了一个新的类lib项目,并引用了 Microsoft.Data.Schema.UnitTesting 和 Microsoft.Data.Schema 以及 Microsoft.Data.Schema.Sql
-
我创建了一个从TestCondition继承的类,并将其称为ExpectedSqlException,定义如下:
- Ive met the requirements of either Ultimate or Premium as my enviroment.
- Created a new class lib project and referenced Microsoft.Data.Schema.UnitTesting and Microsoft.Data.Schema as well as Microsoft.Data.Schema.Sql
-
I created a class inheriting from TestCondition and called it ExpectedSqlException defined as the following
[DisplayName("Expected Sql Exception")]
[DatabaseSchemaProviderCompatibility(typeof(SqlDatabaseSchemaProvider))]
public class ExpectedSqlExceptionTestCondition : TestCondition
{
public override void Assert(System.Data.Common.DbConnection validationConnection, Microsoft.Data.Schema.UnitTesting.ExecutionResult[] results)
{
try
{
base.Assert(validationConnection, results);
throw new DataException("Expected a sql exception");
}
catch (SqlException)
{
}
}
}
跟随 然后,我如何 创建了extensionions.xml文件,然后将其放置在其中 %ProgramFiles%\ Microsoft Visual Studio 10.0 \ VSTSDB \ Extensions" ,并且看起来像这样(类型键/值是我的程序集公共信息,对于您来说应该有所不同)
Following the how to I then created the extentions.xml file that i then placed in "%ProgramFiles%\Microsoft Visual Studio 10.0\VSTSDB\Extensions" and it looks like so (the type key/value is my assembly public info, this should be different for yours)
<?xml version ="1.0" encoding ="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
< extensions assembly ="版本="1" xmlns ="urn:Microsoft.Data.Schema.Extensions" xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation =" urn:Microsoft.Data.Schema.Extensions Microsoft.Data.Schema.Extensions.xsd>
<extensions assembly="" version="1" xmlns="urn:Microsoft.Data.Schema.Extensions" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:Microsoft.Data.Schema.Extensions Microsoft.Data.Schema.Extensions.xsd">
<扩展类型=" ExpectedSqlExceptionTestCondition.ExpectedSqlExceptionTestCondition"程序集="ExpectedSqlExceptionTestCondition,版本= 1.0.0.0,文化=中性,PublicKeyToken = 01a289ad96d7a8a8". enabled ="true"/>
<extension type="ExpectedSqlExceptionTestCondition.ExpectedSqlExceptionTestCondition" assembly="ExpectedSqlExceptionTestCondition, Version=1.0.0.0, Culture=neutral, PublicKeyToken=01a289ad96d7a8a8" enabled="true"/>
</extensions>
</extensions>
- 并在签署大会后将大会注册到GAC中
因此,现在有了新的测试条件,我应该能够在数据库单元测试设计人员中使用它来定义期望, 但是可惜它不起作用:(
So now with my new testcondition i should be able to use it within the database unit testing designer to define expectations, BUT ALAS IT DOES NOT WORK :(
有人可以帮我吗?我缺少什么?
Can someone help me with this? what am i missing?
推荐答案
您好,我遇到了同样的问题.类库项目已成功构建,但遵循了"http://msdn.microsoft.com/zh-cn/library/dd193287(v=VS.100).aspx"链接,但我添加的自定义条件仍未显示在测试条件下拉列表中.什么时候 我按照"http://msdn.microsoft.com/zh-cn/library/dd193287(v=VS.90).aspx"中的步骤执行VS 2008.链接,我可以在VS 2008数据库版单元测试项目中看到自定义条件.我已经观察到%Program Files%\ Microsoft Visual Studio 9.0 \ VSTSDB";包含"Microsoft.Data.Schema.Extensions.xsd";文件,但"C:\ Program Files \ Microsoft Visual Studio 10.0 \ VSTSDB";不包含XSD文件.可能是这个问题.此致Hardik Doshi
Hello, I am facing the same issue. Class library project built successfully but after following "http://msdn.microsoft.com/en-us/library/dd193287(v=VS.100).aspx" link, still my added custom condition is not displayed in test condition drop down list. When I follow the steps for VS 2008 as per "http://msdn.microsoft.com/en-us/library/dd193287(v=VS.90).aspx" link, I am able to see the custom condition in the VS 2008 database edition unit test project. I have observed that "%Program Files%\Microsoft Visual Studio 9.0\VSTSDB" contains "Microsoft.Data.Schema.Extensions.xsd" file but "C:\Program Files\Microsoft Visual Studio 10.0\VSTSDB" does not contains XSD file. May be this is the issue. Regards, Hardik Doshi
这篇关于vs 2010高级版/最终版中的自定义测试条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!