Try our conversational search powered by Generative AI!

How to setup Integration Test Project that gets StructureMap to load properly

Vote:
 

I have added a test project, and I want to test creating pages programtically.  Since the Test Project is the Entry Point, I keep getting this error:

An exception of type 'StructureMap.StructureMapConfigurationException' occurred in StructureMap.dll but was not handled in user code

Additional information: No default Instance is registered and cannot be automatically determined for type 'EPiServer.IContentRepository'

I am referening this article

Create Page Programaticallyhttp://world.episerver.com/documentation/Items/Developers-Guide/Episerver-CMS/9/Content/Creating-a-page-programmatically/

to create pages, but cannot figure out how to get StuctureMap to load it's configuration in a Unit Test Project.

The error happens on this line:

IContentRepository contentRepository = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance();

I have searched and looked at StructureMap's site, but I don't find that useful.

Someone out here has to have created an integration test project to test functionality.  Basically I know the Structure Map configuration needs to be loaded by the test project, but I cannot figure out how do that.

Thanks,

-Bernie

#143773
Jan 30, 2016 19:32
Vote:
 

Hi,

I think that this blog post describe solution for your problem:

http://tedgustaf.com/blog/2013/10/unit-testing-in-episerver-7/

#143783
Feb 01, 2016 10:01
Vote:
 

I don't want to MOCK..   I want to do Integration tests, which means no mocking, actual objects are needed for that.

#143798
Feb 01, 2016 13:16
Vote:
 

This repo should help understand how to run integration test

https://github.com/nicklasisraelsson/EPiCommerce.Integration.Sample

#144129
Feb 08, 2016 11:30
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.