简体   繁体   中英

How to copy resource (any content) files to output folder when NUnit's shadow copying is turned on?

Of course there is an option to turn it off (by default it is on.) However I like to be able to make incremental changes to the DLL while a copy of NUnit GUI is up.

However I couldn't find much documentation for this feature (apart from the need ) So the problem is like this

With Shadow copy enabled in NUnit,
my SUT (Dll) invokes an executable (also in the output folder ; via references). Now this executable needs certain configuration/modifier files to be in the same folder as the executable. How do I ensure that my reference modifier files are reachable by the executable during the test ?

Does NUnit shadow copy just the SUT dll or all the linked/referenced dlls/execs ? What do I need to do in the test setup such that any supporting files for the SUT are copied correctly?

I see that

  • executingAssembly.Codebase gives me the original output folder
  • executingAssembly.Location gives me the shadow copy folder.

I'm not sure if I am being lucid here - let me know if I need to update

The real issue is usually finding where they are during the tests.

Use this instead of Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) :

string exeDirectory = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);

See Trouble with NUnit when determining the assembly's directory

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM