views:

28

answers:

2

Hey all,

I'm trying to create a short bash script someone could run in cygwin to execute all nunit tests in a .NET project using nunit-console. Currently i have the system version of nunit aliased to "nunit" so if i run "nunit" it will execute nunit-console.

My first step was to try and find all the test assemblies recursively. This MOSTLY works:

find . -name *.Test*.dll

but it returns both /obj and /bin versions of a dll.

Second i need to figure out a way to pass all of the results from that find to nunit, preferably in one execution which so far I have no clue how to do.

Any cygwin / bash gurus out there that can help?

A: 

Something like this:

find . -name "*.Test*.dll" -path /path/to/skip -prune -o -exec nunit {} \;

Untested - try it like this first to see if it gives you the correct files:

find . -name "*.Test*.dll" -path /path/to/skip -prune -o -print
Dennis Williamson
no luck with this. as is it outputs a ton of files not just Test*.dlls when i get rid of -o it prints nothing. without the -path -prune -o if i exec the results against nunit i get "No such file or directory" for each entry.
JoshReedSchramm
+1  A: 

Hi Josh,

Does the list of assemblies change dynamically? If it doesn't change often then you probably don't need to determine what assemblies to run on at runtime. Rather, your problem is better solved through the use of an NUnit project. For example, create the file tests.nunit, with contents:

<NUnitProject>
  <Settings activeconfig="Debug"/>
  <Config name="Debug">
    <assembly path="ProjectA\bin\Debug\App.dll"/>
    <assembly path="ProjectB\bin\Debug\Widget.dll"/>
  </Config>
  <Config name="Release">
   <assembly path="ProjectA\bin\Release\App.dll"/>
    <assembly path="ProjectB\bin\Release\Widget.dll"/>
  </Config>
</NUnitProject>

Running nunit-console tests.nunit would run all the tests in the App and Widget assemblies, in the Debug folder. You can also omit the Config and activeconfig stuff if it's not relevant and just list assemblies that will always be tested regardless of active configuration.

Check out the NUnit documentation on running on multiple assemblies.

imoatama
huh didn't know about this. This would probably accomplish the root goal. Thanks.
JoshReedSchramm