SSDT 单元测试:.从配置文件读取 SQL Server 单元测试设置时出错 [英] SSDT Unit Test:. An error occurred while SQL Server unit testing settings were being read from the configuration file

查看:43
本文介绍了SSDT 单元测试:.从配置文件读取 SQL Server 单元测试设置时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Visual Studio 2013 专业版中创建了一个数据库项目.然后通过右键单击存储过程之一并选择创建单元测试来添加单元测试.选择创建一个新的 VB 测试项目.然后右击新创建的测试项目,选择SQL Server测试配置,选择localdb数据库,配置好需要部署的项目.重建解决方案,运行所有测试(两个测试).测试总是失败并出现此错误:

I created a database project in Visual Studio 2013 professional. Then added a unit test by right click on one of the stored procedure and select Create Unit Tests. Selected to create a new VB test project. Then right click on the newly created test project and select SQL Server Test Configuration, choose localdb database and configured the project that need to be deployed. Rebuild the solution, Run All tests (two tests). Tests always fail with this error:

消息:从配置文件读取 SQL Server 单元测试设置时出错.单击测试项目,从 SQL 菜单中打开 SQL Server 测试配置对话框,将设置添加到对话框中,然后重建项目.

Message: An error occurred while SQL Server unit testing settings were being read from the configuration file. Click the test project, open the SQL Server Test Configuration dialog box from the SQL menu, add the settings to the dialog box, and rebuild the project.

堆栈跟踪:在 Microsoft.Data.Tools.Schema.Sql.UnitTesting.SqlDatabaseTestService.OpenProcessConfig()在 Microsoft.Data.Tools.Schema.Sql.UnitTesting.SqlDatabaseTestService.DeployDatabaseProject()在 *************.Tests.SqlDatabaseSetup.InitializeAssembly(TestContext ctx) 在 C:\Projects************************.Tests\SqlDatabaseSetup.vb:line 15

StackTrace: at Microsoft.Data.Tools.Schema.Sql.UnitTesting.SqlDatabaseTestService.OpenProcessConfig() at Microsoft.Data.Tools.Schema.Sql.UnitTesting.SqlDatabaseTestService.DeployDatabaseProject() at *************.Tests.SqlDatabaseSetup.InitializeAssembly(TestContext ctx) in C:\Projects*********************.Tests\SqlDatabaseSetup.vb:line 15

推荐答案

好像是VS 2013生成的app.config是空的.我在网上做了一些研究,并进行了大量尝试和错误,并提供了以下 app.config:

It seems to be that the app.config that is get generated by VS 2013 is empty. I did some research online and lots of try and error and came with the following app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="system.data.localdb" type="System.Data.LocalDBConfigurationSection,System.Data,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089"/>
    <section name="SqlUnitTesting_VS2013" type="Microsoft.Data.Tools.Schema.Sql.UnitTesting.Configuration.SqlUnitTestingSection, Microsoft.Data.Tools.Schema.Sql.UnitTesting, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  </configSections>
  <system.data.localdb>
    <localdbinstances>
      <add name="(localdb)\ProjectsV12" version="12.0" />
    </localdbinstances>
  </system.data.localdb>
  <SqlUnitTesting_VS2013>
    <DatabaseDeployment DatabaseProjectFileName="..\..\..\Database_Project_Name\Database_Project_Name.sqlproj"
        Configuration="Debug" />
    <DataGeneration ClearDatabase="true" />
    <ExecutionContext Provider="System.Data.SqlClient" ConnectionString="Data Source=(localdb)\ProjectsV12;Initial Catalog=Database_Name;Integrated Security=True;Pooling=False;Connect Timeout=30"
        CommandTimeout="30" />
    <PrivilegedContext Provider="System.Data.SqlClient" ConnectionString="Data Source=(localdb)\ProjectsV12;Initial Catalog=Database_Name;Integrated Security=True;Pooling=False;Connect Timeout=30"
        CommandTimeout="30" />
  </SqlUnitTesting_VS2013>
</configuration>

现在我收到以下错误:无法部署数据库项目 C:\Projects\Database_Project_Name\Database_Project_Name\Database_Project_Name.sqlproj.但这似乎是因为我的数据库依赖于其他数据库,我需要将其他数据库与我的数据库一起部署.

Now I get the following error: Failed to deploy database project C:\Projects\Database_Project_Name\Database_Project_Name\Database_Project_Name.sqlproj. But this seems to be because my database depends on other databases and I need to deploy the other database with my database.

这篇关于SSDT 单元测试:.从配置文件读取 SQL Server 单元测试设置时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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