2017-06-05 50 views
0

我们有一个解决方案,它是由TFS和SQL服务器单元测试构建的,它们应该在每个版本上运行。测试部分还包含一个数据库项目,在运行测试之前应将其部署到localDB。 对于SQL Server单元测试项目的配置是:TFS上的SQL服务器单元测试版本

<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>

一切工作的罚款我的本地机器上,而在TFS失败与错误:

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.

的人承担测试在TFS 2013上运行良好,但在升级到TFS 2015后,我们开始出现此错误。试过这里和互联网上找到的不同解决方案,但没有任何帮助。我错过了什么? 谢谢。

回答

0

尝试使用另一个SQL Server实例(不是localdb,使用另一个SQL Server实例对我来说工作正常)。

另一方面,您使用的是Windows身份验证,因此请确保构建服务帐户对目标SQL Server具有足够的权限(例如,创建数据库)。

+0

我试图使用另一个SQL Server实例(SQL Server 2014和SQL Express),但没有运气。还尝试玩服务帐户的权限,并通过不同的凭据,而不是使用Windows身份验证,结果相同 – Andrew

+0

@Andrew您可以从另一台机器连接到该SQL Server吗?不同的凭证是否意味着SQL帐户(SQL身份验证)?尝试将服务帐户更改为您的帐户并检查结果。 –

+0

谢谢你的回复。 TFS和SQL服务器都设置在我的本地机器上,所以是的,我可以连接到SQL服务器。 “尝试将服务帐户更改为您的帐户”可能没有得到您的想法。 – Andrew

相关问题