The addin installation is cumberson and should be done automatically. i.e. When a test method/class has more attributes, these should be installed.
This can be done by parsing the assemblies referenced by the test assembly:
Example fix:
in src\NUnitCore\core\CoreExtensions.cs
public void InstallAdhocExtensions(Assembly assembly)
{
InstallAdhocExtensionsForOneAssembly(assembly);
foreach (AssemblyName name in assembly.GetReferencedAssemblies())
{
try
{
Assembly referencedAssembly = Assembly.Load(name);
// ignore mscorlib and nunit assemblies
if (referencedAssembly != typeof(object).Assembly &&
referencedAssembly != this.GetType().Assembly)
{
InstallAdhocExtensionsForOneAssembly(Assembly.Load(referencedAssembly));
}
}
catch
{
}
}
}
private void InstallAdhocExtensionsForOneAssembly(Assembly assembly)
{
foreach (Type type in assembly.GetExportedTypes())
{
if (type.GetCustomAttributes(typeof(NUnitAddinAttribute), false).Length == 1)
InstallAddin(type);
}
}
Logged In: YES
user_id=586918
Originator: NO
This fix makes the assumption that the addin is defined in the same assembly as the attribute, which is not the pattern I have been advocating for writing add-ins. Unfortunately, this bug points out to me that all my samples use the same pattern. I'll put the fix in, but I don't think it's a long-term solution - the so-called 'adhoc' extension facility is not documented because it was only intended for temporary use by extension developers.
Logged In: YES
user_id=1781735
Originator: YES
Thanks for explaining this.
We do need a better long term solution.
Logged In: YES
user_id=586918
Originator: NO
Postponed due to problems that arise when the same addin is referenced by multiple tests.