I have an assembly that I am trying to write NUnit tests for that
requires an assembly binding redirect. I have tried adding the
redirect to the test config file, but NUnit doesn't seem to take
notice of it. Does anyone have any experience of trying to do this, or
knows whether it is supported or not supported in NUnit?
[Why don't I just keep everything in sync. so I don't need the
redirect? Because an update to one of the dependent systems means
various build/install/uninstall steps and takes about 15 minutes. So
the assembly binding redirect has saved me a lot of time :)]
I am using a external component library / DLL which unfortunately does
not use the same version of the nUnit DLL(s) and have not been able to
get around this yet.
> I have an assembly that I am trying to write NUnit tests for
> that requires an assembly binding redirect. I have tried
> adding the redirect to the test config file, but NUnit
> doesn't seem to take notice of it. Does anyone have any
> experience of trying to do this, or knows whether it is
> supported or not supported in NUnit?
If you have used the correct name and location for your config,
the binding redirects should be used. This is a function of
how .NET works rather than NUnit.
NUnit's part is to tell .NET about the config file, which means
you need to follow certain conventions. If you have not already
done so, add something to the config file that allows you to
test that it is being loaded. A simple AppSetting will do it.
Charlie
Charlie
All instructions that I have seen to date or not very explicit as too
exactly which file these redirects need to be in and how these are
picked up by nUNIT
--
You received this message because you are subscribed to the Google Groups "NUnit-Discuss" group.
To post to this group, send email to nunit-...@googlegroups.com.
To unsubscribe from this group, send email to nunit-discus...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nunit-discuss?hl=en.
The docs describe how to use config files here...
http://nunit.org/?p=configFiles&r=2.5.3
Here's a blog post I wrote about it...
http://nunit.org/blogs/?p=9
Generally, the NUnit documentation assumes you are already
familiar with stuff like this, but maybe it would be a
good idea to have some basic info available.
From: nunit-...@googlegroups.com [mailto:nunit-...@googlegroups.com] On Behalf Of Simone Busoli
Sent: Wednesday, January 13, 2010 10:38 AM
To: nunit-...@googlegroups.com
Subject: Re: [nunit-discuss] Re: Configuring NUnit to use assembly binding redirect for test
Charlie's suggestion of using an appsetting was a good one, I was
fairly sure the config file wasn't being picked up from the fusion
log, but using an appsetting makes it clear. And I can leave that in
so when someone else checks it out and their build doesn't find the
config file, they will know that immediately from my comments on the
failing appsetting test rather than scratching their head over the
library load failure like I did...
What I found was that I needed to follow the 'single AppDomain'
instructions - and oops, I didn't read that carefully enough before to
see that it requires the config file to relate to the NUnit project
file. The appDomain setting doesn't seem to affect this, maybe because
I only have a single test assembly. That doesn't agree with
what the docs say, though.
Thanks for your help, guys - the main thing was getting a 'yes, this
should work' to encourage me to keep on trying. :-)
On 13 Jan, 22:16, "Charlie Poole" <char...@nunit.com> wrote:
> Exactly! Often people indicate that the config file is being ignored when
> the
> real problem is that their entry is not in proper form. It's better to be
> absolutely
> sure which problem you're having.
>
> Once you know that the file is being read, you can then work on getting
> the binding redirect right.
>
> Charlie
>
> _____
>
> From: nunit-...@googlegroups.com [mailto:nunit-...@googlegroups.com]
> On Behalf Of Simone Busoli
> Sent: Wednesday, January 13, 2010 10:38 AM
> To: nunit-...@googlegroups.com
> Subject: Re: [nunit-discuss] Re: Configuring NUnit to use assembly binding
> redirect for test
>
> Whatty, as Charlie suggested it's not an NUnit feature, it's how .NET works.
> You need to follow its conventions for it to load your configuration file.
> What Charlie suggests is adding something to the appSettings section of the
> configuration file and try reading it from one of the tests to check that
> the configuration file is really being used during the test run.
>
> <mailto:nunit-discuss%2Bunsu...@googlegroups.com> .
> I have got my binding redirect working now.
>
> Charlie's suggestion of using an appsetting was a good one, I
> was fairly sure the config file wasn't being picked up from
> the fusion log, but using an appsetting makes it clear. And I
> can leave that in so when someone else checks it out and
> their build doesn't find the config file, they will know that
> immediately from my comments on the failing appsetting test
> rather than scratching their head over the library load
> failure like I did...
I do that with NUnit's own tests. If the config file can't be
found, the failure says "Config file not found."
> What I found was that I needed to follow the 'single AppDomain'
> instructions - and oops, I didn't read that carefully enough
> before to see that it requires the config file to relate to
> the NUnit project file. The appDomain setting doesn't seem to
> affect this, maybe because I only have a single test
> assembly. That doesn't agree with what the docs say, though.
This confuses lots of people and I've come to believe it was
a mistake to use two different conventions for single assemblies
and projects. We'll probably break compatibilit with NUnit 3.0
in order to make this simpler.
Charlie