Re: Problem running tests from a network share - BUG
"Butler, Tony (London)" <[email protected]>
| Newsgroups | gmane.comp.windows.dotnet.nunit.user |
|---|---|
| Message-ID | <289EBA527A6A47418295E92F70ACFB32011C4A28@MLLNA225MB.emea.win.ml.com> |
Hi again,
Following on from my earlier email, I can answer my own question as to
the cause of the problem - it seems to be a bug in
NUnit.Core.TestFixtureBuilder as follows.
// TODO: This logic should be in shared source
public static string GetAssemblyPath( Assembly assembly )
{
string path = assembly.CodeBase;
// If it wasn't loaded locally, use the Location
if ( !path.StartsWith( Uri.UriSchemeFile ) )
return assembly.Location;
// Skip over the file://
int start = Uri.UriSchemeFile.Length + Uri.SchemeDelimiter.Length;
if ( path[start] == '/' && path[start+2] == ':' )
++start;
return path.Substring( start );
}
Since my tests are on the network, assembly.CodeBase returns
file:\\server\share\path\to\testassembly.DLL
<file://server/share/path/to/testassembly.DLL> , which is then stripped
by path.Substring(start) to server\share\path\to\testassembly.DLL
NUnit.Core.TestFixture is calling GetAssemblyPath in the
TestResultMethod:
public override TestResult Run(EventListener listener, ITestFilter
filter)
{
using ( new DirectorySwapper( Path.GetDirectoryName(
TestFixtureBuilder.GetAssemblyPath( FixtureType ) ) ) )
{
return base.Run(listener, filter);
}
}
It passes the result to Path.GetDirectoryName, which returns
server\share\path\to, and then DirectorySwapper tries to set
Environment.CurrentDirectory to this value.
The actual error thrown is:
Could not find a part of the path
'C:\Work\NUnit\src\ConsoleRunner\nunit-console-exe\bin\Debug2005\server\
share\path\'.
(I guess this error is not being fully propagated up the food chain,
which is why I got the object reference error when running the code
normally).
So basically NUnit is trying to set the current directory to a
non-existent one is arrived at by incorrect handling of file:// paths.
As a side note, I verified that this is the problem by quickly hard
coding the result of GetAssemblyPath to return the proper path for my
particular assembly and all tests then ran fine.
Can you please confirm that this is now classed as a bug and, ideally,
provide some timeframe for fixing it?
I don't want to just change my local copy of nunit as, given that
file:// is being explicitly stripped from the path, one would assume
there was a very specific reason for doing this which may still be valid
in other cases?
many thanks,
Tony.
--------------------------------------------------------
This message w/attachments (message) may be privileged, confidential or proprietary, and if you are not an intended recipient, please notify the sender, do not use or share it and delete it. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Merrill Lynch. Subject to applicable law, Merrill Lynch may monitor, review and retain e-communications (EC) traveling through its networks/systems. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or error-free. This message is subject to terms available at the following link: http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch you consent to the foregoing.
--------------------------------------------------------
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Nunit-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nunit-users