Sometimes you may prefer not to put your test assemblies into the bin folder of your Web. Below are some options that you might find useful. These options are limited, however, because your assembly should be visible to the Asp.Net runtime. If you decide to put your test assembly in a folder different from the bin folder, you should make modifications to your web.config file.
While other, more complicated, solutions exist, they are not implemented in the current version of Ivonna.
Using the probing configuration element
The probing element specifies application base subdirectories for the common language runtime to search when loading assemblies.
<configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <probing privatePath="bin;bin2\subbin;bin3"/> </assemblyBinding> </runtime> </configuration> | |
You can put your test assembly in any folder included in the list. Note, however, that the list can contain only subfolders of the Web root folder.
The constructor arguments for the RunOnWebAttribute include the physical path to the Web root folder. If you use the default constructor, this path is relative and equals to "..", which means that the Web is located in the parent folder of the test assembly. If you use a folder like "bin2/subbin", for example, you should set the physical web path explicitly, either relative or absolute.
Using the codeBase element
The codeBase element allows you to specify the location of your test assembly.
<configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="MyWeb.Tests"/> <codeBase href="file:///C:\MyWeb.Tests.dll" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration> | |
This approach has an important restriction. You can put your test assembly outside the application root only if it is strongly signed. So, you'll have to sign it with each build, which can affect the development speed.
Using a precompiled Web
You can publish your Web locally and put your test assembly in the bin folder of the published Web. This approach might be even worse, however, because each small change in the production code would require re-publishing, which can be quite slow for any serious web.
Precompilation has another benefit: this is the only way you can reference your Web's classes from the test assembly. For example, you should use it when you want to test-drive your App_Code classes.