简体   繁体   English

TFS构建上的SQL Server单元测试

[英]SQL server unit test on TFS build

We has a solution which is being built by TFS and SQL server unit tests which should be run on each build. 我们有一个应由TFS和SQL Server单元测试构建的解决方案,应在每个构建上运行。 The tests part also consists of a Database project which should be deployed to localDB before tests are running. 测试部分还包含一个数据库项目,应在运行测试之前将其部署到localDB。 The config for SQL server unit test project is: SQL Server单元测试项目的配置为:

 <configSections> <section name="SqlUnitTesting" type="Microsoft.Data.Tools.Schema.Sql.UnitTesting.Configuration.SqlUnitTestingSection, Microsoft.Data.Tools.Schema.Sql.UnitTesting, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections> <connectionStrings> <add name="SnapDBContext" connectionString="Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=SampleDatabase;Integrated Security=SSPI;" providerName="System.Data.SqlClient" /> </connectionStrings> <SqlUnitTesting> <DatabaseDeployment DatabaseProjectFileName="..\\..\\..\\..\\Database\\SampleDatabase.sqlproj" Configuration="Debug" /> <DataGeneration ClearDatabase="true" /> <ExecutionContext Provider="System.Data.SqlClient" ConnectionString="Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=SampleDatabase;Integrated Security=True;Pooling=False" CommandTimeout="30" /> <PrivilegedContext Provider="System.Data.SqlClient" ConnectionString="Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=SampleDatabase;Integrated Security=True;Pooling=False" CommandTimeout="30" /> </SqlUnitTesting> <entityFramework> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework" /> <providers> <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> </providers> </entityFramework> 

Everything work fine on my local machine but on TFS it fails with an error: 一切在我的本地计算机上都可以正常工作,但是在TFS上它会失败并显示错误:

An error occurred while SQL Server unit testing settings were being read from the configuration file. 从配置文件读取SQL Server单元测试设置时发生错误。 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. 单击测试项目,从SQL菜单中打开“ SQL Server测试配置”对话框,将设置添加到对话框中,然后重新生成项目。

The guys assumes that the tests worked fine on TFS 2013 but after the upgrading to TFS 2015 we started to get this error. 伙计们假设测试在TFS 2013上运行良好,但是在升级到TFS 2015之后,我们开始遇到此错误。 Tried different solutions found here and over the internet but nothing helps. 尝试了在此处和通过Internet找到的不同解决方案,但没有任何帮助。 What am I missing? 我想念什么? Thank you. 谢谢。

Try to use another SQL Server instance (not localdb, using another SQL Server instance works fine for me). 尝试使用另一个SQL Server实例(不是localdb,使用另一个SQL Server实例对我来说很好)。

On the other hand, you are using windows authentication, so make sure the build service account has the enough permission (eg create database) for target SQL Server. 另一方面,您正在使用Windows身份验证,因此请确保构建服务帐户具有对目标SQL Server足够的权限(例如,创建数据库)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM