[英]Visual Studio 2015 Unit Test Inconsistency
I am receiving inconsistent unit test results after moving to VS2015 after being on VS2013. 在VS2013上升级到VS2015后,我收到不一致的单元测试结果。 On VS2013, the unit tests were consistently passing.
在VS2013上,单元测试始终通过。 In VS2015, the unit tests fail if all are run at once or it is an automated Jenkins build.
在VS2015中,如果全部一次运行或者是Jenkins自动构建,则单元测试将失败。 If the unit tests are individually run or all the failed tests are run at once, they pass.
如果单元测试单独运行或所有失败的测试一次运行,则它们通过。
This may be an EF6 issue. 这可能是EF6问题。 The error message I receive when all tests are run is...
运行所有测试时收到的错误消息是...
Test Name: GetQuoteService_NoExceptions
Test FullName: MEA.SmartApp.Business.Factories.APV.UnitTests.QuoteFactoryTest.GetQuoteService_NoExceptions
Test Source: C:\MetLife_Sourcecode\Common\DEV2\MEA.Smartapp.Common\Unit Tests\MEA.SmartApp.Business.Factories.APV.UnitTests\QuoteFactoryTest.cs : line 15
Test Outcome: Failed
Test Duration: 0:00:00.00737
Result StackTrace: 结果StackTrace:
at System.Data.Entity.Infrastructure.DependencyResolution.ProviderServicesFactory.GetInstance(String providerTypeName, String providerInvariantName)
at System.Data.Entity.Internal.AppConfig.<.ctor>b__2(ProviderElement e)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at System.Data.Entity.Internal.AppConfig.<.ctor>b__1()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at System.Lazy`1.get_Value()
at System.Data.Entity.Internal.AppConfig.get_DbProviderServices()
at System.Data.Entity.Infrastructure.DependencyResolution.AppConfigDependencyResolver.RegisterDbProviderServices()
at System.Data.Entity.Infrastructure.DependencyResolution.AppConfigDependencyResolver.GetServiceFactory(Type type, String name)
at System.Data.Entity.Infrastructure.DependencyResolution.AppConfigDependencyResolver.<>c__DisplayClass1.<GetService>b__0(Tuple`2 t)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at System.Data.Entity.Infrastructure.DependencyResolution.AppConfigDependencyResolver.GetService(Type type, Object key)
at System.Data.Entity.Infrastructure.DependencyResolution.DbDependencyResolverExtensions.GetServiceAsServices(IDbDependencyResolver resolver, Type type, Object key)
at System.Data.Entity.Infrastructure.DependencyResolution.AppConfigDependencyResolver.GetServices(Type type, Object key)
at System.Data.Entity.Infrastructure.DependencyResolution.ResolverChain.<>c__DisplayClass6.<GetServices>b__5(IDbDependencyResolver r)
at System.Linq.Enumerable.<SelectManyIterator>d__1`2.MoveNext()
at System.Linq.Enumerable.<ConcatIterator>d__1`1.MoveNext()
at System.Linq.Enumerable.<OfTypeIterator>d__1`1.MoveNext()
at System.Data.Entity.Utilities.IEnumerableExtensions.Each[T](IEnumerable`1 ts, Action`1 action)
at System.Data.Entity.Infrastructure.DependencyResolution.InternalConfiguration.Lock()
at System.Data.Entity.Infrastructure.DependencyResolution.DbConfigurationManager.<.ctor>b__1()
at System.Lazy`1.CreateValue()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Lazy`1.get_Value()
at System.Data.Entity.Infrastructure.DependencyResolution.DbConfigurationManager.GetConfiguration()
at System.Data.Entity.DbContext.InitializeLazyInternalContext(IInternalConnection internalConnection, DbCompiledModel model)
at System.Data.Entity.DbContext..ctor(String nameOrConnectionString)
at MEA.SmartApp.Contexts.APV.AVMDB..ctor() in C:\MetLife_Sourcecode\Common\DEV2\MEA.Smartapp.Common\DataAccessLayer\MEA.SmartApp.Contexts.APV\AVMDB.Context.cs:line 19
at MEA.SmartApp.Business.Factories.APV.QuoteFactory.GetAvmBusinessService() in C:\MetLife_Sourcecode\Common\DEV2\MEA.Smartapp.Common\BusinessLogicLayer\MEA.SmartApp.Business.Factories.APV\QuoteFactory.cs:line 65
at MEA.SmartApp.Business.Factories.APV.QuoteFactory.GetQuoteService(APVTransactionCode transactionCode) in C:\MetLife_Sourcecode\Common\DEV2\MEA.Smartapp.Common\BusinessLogicLayer\MEA.SmartApp.Business.Factories.APV\QuoteFactory.cs:line 46
at MEA.SmartApp.Business.Factories.APV.UnitTests.QuoteFactoryTest.GetQuoteService_NoExceptions() in C:\MetLife_Sourcecode\Common\DEV2\MEA.Smartapp.Common\Unit Tests\MEA.SmartApp.Business.Factories.APV.UnitTests\QuoteFactoryTest.cs:line 18
Result Message:
Test method MEA.SmartApp.Business.Factories.APV.UnitTests.QuoteFactoryTest.GetQuoteService_NoExceptions threw exception:
**System.InvalidOperationException: The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded**. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
*I realize this isnt a true unit test since it is trying to connect to a DB, so if you have any suggestions of how to fix that, let me know. *我意识到这并不是真正的单元测试,因为它正尝试连接到数据库,因此,如果您对如何解决该问题有任何建议,请告诉我。
@KeithPayne - After running the failing unit tests with different sets of other unit tests, I was able to prove that it was one other test that caused the entity framework tests to fail. @KeithPayne-在使用其他不同的其他单元测试集运行失败的单元测试之后,我能够证明是另一个测试导致实体框架测试失败。 So you were right about the parallel execution.
因此,您对并行执行是正确的。
There were two outstanding attributes of that unit test that caused the entity framework unit tests to fail. 该单元测试的两个突出属性导致实体框架单元测试失败。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.