SSDT Unit Test:. An error occurred while SQL Server unit testing settings were being read from the configuration file

别说谁变了你拦得住时间么 提交于 2019-12-11 04:34:35

问题


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:

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.

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


回答1:


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>

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.



来源:https://stackoverflow.com/questions/26896611/ssdt-unit-test-an-error-occurred-while-sql-server-unit-testing-settings-were-b

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!