public virtual void SetUp() { try { referenceResolver = NailsTestsConfigurator.Instance.AcquireConfiguration(this); InjectTestProperties(); configured = true; PersistenceContext.OpenSession(); if (TestsInUnitOfWork) { uow = WorkContextProvider.CurrentContext.BeginUnitOfWork(new UnitOfWorkInfo(true)); } } catch (Exception) { //if configuration throws an exception, need to release the lock. This is needed because in MSTest lifecycle if Initialize method fails, the Cleanup is not called NailsTestsConfigurator.Instance.ReleaseConfiguration(); throw; } }