This post has been migrated from www.experimentsincode.com, we apologise if some of the images or content is missing

Posts in this series: This post deals with the limitations of unit testing Sitecore via the NUnit GUI.

Deleting Items

If you try to delete and item you will receive the following error:
at Sitecore.Tasks.ItemEventHandler.OnItemDeleted(Object sender, EventArgs args)
at Sitecore.Events.Event.EventSubscribers.RaiseEvent(String eventName, Object[] parameters, EventResult result)
at Sitecore.Events.Event.EventSubscribers.RaiseEvent(String eventName, Object[] parameters)
at Sitecore.Events.Event.RaiseEvent(String eventName, Object[] parameters)
at Sitecore.Events.Event.RaiseItemDeleted(Object sender, ItemDeletedEventArgs args)
at Sitecore.Events.Event.DataEngine_ItemDeleted(Object sender, ExecutedEventArgs`1 e)
at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
at Sitecore.Data.Engines.EngineCommand`2.RaiseExecuted()
at Sitecore.Data.Engines.EngineCommand`2.Executed()
at Sitecore.Data.Engines.EngineCommand`2.Execute()
...
The solution to this problem is to remove the the following event from the item:deleted event
<handler type="Sitecore.Tasks.ItemEventHandler, Sitecore.Kernel" method="OnItemDeleted" />

Log4Net

When running you unit tests you might notice that in the Output you receive this error:
log4net:ERROR DOMConfigurator: Could not create Appender [LogFileAppender] of type [log4net.Appender.SitecoreLogFileAppender, Sitecore.Logging]. Reported error follows.
log4net:ERROR DOMConfigurator: Could not create Appender [LogFileAppender] of type [log4net.Appender.SitecoreLogFileAppender, Sitecore.Logging]. Reported error follows.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: str
   at System.Security.Permissions.FileIOPermission.HasIllegalCharacters(String[] str)
   at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
   at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String path)
   at System.Web.InternalSecurityPermissions.get_AppPathDiscovery()
   at System.Web.HttpRuntime.get_AppDomainAppPath()
   at log4net.Appender.SitecoreLogFileAppender.MapPath(String fileName)
   at log4net.Appender.SitecoreLogFileAppender.set_File(String value)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
   at log4net.Repository.Hierarchy.DOMHierarchyConfigurator.SetParameter(XmlElement element, Object target)
   at log4net.Repository.Hierarchy.DOMHierarchyConfigurator.ParseAppender(XmlElement appenderElement)
This won't cause any problems with your unit tests but you might to remove it. To do this remove the appender and root elements from beneath the log4net element in the App.config. As I find more limits to what can and can't be achieved  via this method of testing I will add them to the blog.