Unit test issues
Hi all, i'm having trouble getting TeamCity to run my unit tests. The tests all pass fine in my development environment, and they even work if i open VS in the server that has TeamCity installed, but whenever i run a build through TeamCity i get the following exception:
Initialization method MuniAxis.Tests.Security.SecurityManagerTest.InitTests threw exception. Microsoft.Practices.ServiceLocation.ActivationException: Microsoft.Practices.ServiceLocation.ActivationException: Activation error occured while trying to get instance of type IPersistanceSessionManager, key "" ---> Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency failed, type = "MuniAxis.Persistence.Interfaces.Common.IPersistanceSessionManager", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The current type, MuniAxis.Persistence.Interfaces.Common.IPersistanceSessionManager, is an interface and cannot be constructed. Are you missing a type mapping?
-----------------------------------------------
At the time of the exception, the container was:
Resolving MuniAxis.Persistence.Interfaces.Common.IPersistanceSessionManager,(none)
---> System.InvalidOperationException: The current type, MuniAxis.Persistence.Interfaces.Common.IPersistanceSessionManager, is an interface and cannot be constructed. Are you missing a type mapping?.
at Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.ThrowForAttemptingToConstructInterface(IBuilderContext context)
at BuildUp_MuniAxis.Persistence.Interfaces.Common.IPersistanceSessionManager(IBuilderContext )
at Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
--- End of inner exception stack trace ---
at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, String name, IEnumerable`1 resolverOverrides)
at Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name, ResolverOverride[] resolverOverrides)
at Microsoft.Practices.Unity.UnityServiceLocator.DoGetInstance(Type serviceType, String key)
at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
--- End of inner exception stack trace ---
at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance[TService]()
at MuniAxis.Tests.BaseTest.InitTests()
Any ideas??
Thanks, Gonzalo
Please sign in to leave a comment.
Hi Gonzalo
It seems as account/security issue. Please check agent's service account has enough permissions.
For test, you can launch the agent interactively.
Michael
Michael, the service is running under a user that's an administrator for the computer so permissions shouldn't be an issue. Also, this doesn't happen for all tests, but only for a few of them (they all pass fine if i run them in my dev environment and even from visual studio in the server where TeamCity is installed).
Thanks, Gonzalo
Is TeamCity Agent service uses the same account, as in session where you start tests from Visual Studio?
Can you try to start the agent without a service, but within user session - as described in the link above.
Thanks