Unit testing your EPiServer site

Vote:
 
Hiya, I'm trying to unit test certain classes within my EPiServer project. However, whenever I try to run the tests I get the following error: "Test method RFKO_Tests.RFPropertyGetter_Tests.TestMethod1 threw exception: System.IO.FileNotFoundException: Could not find file 'C:\[PathToWebApp]\TestResults\[username_computername] 2007-11-14 12_15_3\Outweb.config'.." With the following stack trace: at EPiServer.ConfigFileSettings.ᐁ() at EPiServer.ConfigFileSettings.get_AllAppSettings() at EPiServer.ApplicationConfiguration..ctor(String configFileName) at EPiServer.Global.get_EPConfig() at EPiServer.DataAccess.DynamicPropertiesDB..ctor() at EPiServer.DataAbstraction.DynamicProperty.ListForPage(PageReference pageLink) at EPiServer.DataAbstraction.DynamicProperty.Load(PageReference pageLink, String propertyName) Has anyone seen this before? // Peter
#13270
Nov 14, 2007 14:13
Vote:
 
I'm no expert on unit testing, but the error message would indicate that EPiServer is having problems being run in a non-web environment (which would not surprise me a bit :-) ) /Steve
#15557
Nov 15, 2007 21:42
Vote:
 
We use unit testing internally at EPiServer and have this base class to setup the configuration, hope it helps. public abstract class BaseTest { private static System.Configuration.Configuration _config = null; public static string TempDir = @"c:\temp\"; private const string sourceFile = "..\\out\\web.config"; public BaseTest() { InitializeNewConfig(); } public static void InitializeNewConfig() { _config = System.Configuration.ConfigurationManager.OpenExeConfiguration(sourceFile); EPiServer.Configuration.Settings.InitializeAllSettings(_config); // Ensure we have no cached paths in case we have changed application root settings etc. EPiServer.Web.PermanentLinkMapStore.Clear(); } }
#15558
Jan 21, 2008 11:26
Vote:
 
Hello Per, Thanks for the reply. I forgot to mention that we're using EPiServer 4.61, so that code doesn't work with our version. I don't know if there are any similar to these in the old EPi: EPiServer.Configuration.Settings.InitializeAllSettings(_config); EPiServer.Web.PermanentLinkMapStore.Clear(); Cheers! // Peter
#15559
Jan 25, 2008 10:14
* 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.