Question

I'm writing my rakefile and have it building just fine. However, I am trying to figure out a pattern for listing the test project dlls for nunit to run.

My projects for this solution are in a folder with a lot of other projects and a lot of other test projects, so I can't just run all the tests from all the projects that have .test in their name or something like that. I can't look in the bin folder that the build produces because while the test projects are in the solution they are not referenced by the the main project (mvc project in this case).

Is there anyway to interigate the sln file to get the list of test projects and the get the dlls from that? or should I reference my test projects in the main project so I can pull the dlls out of the bin? Should I just shut up and hard code references to the test projects?

Thanks,

R

Was it helpful?

Solution

Raif, I'm worried, based on your solution/project structure, that you answered your own question... the most "obvious" solution is to shut up and hard code them ;) It's not a terrible option and it gets you tests in your build right now.

nunit :test do |nunit|
  nunit.command = "whatever.exe"
  nunit.assemblies = [
    "source/foo.tests/bin/Release/foo.tests.dll",
    "source/bar.tests/bin/Release/bar.tests.dll"
  ]
end

If you want a fancy method, you'll have to make some changes. You could add something to the test project names to distinguish them from the others. Then, you just search for them all in the right root.

nunit :test do |nunit|
  nunit.command = "whatever.exe"
  nunit.assemblies = FileList["source/**/bin/Release/*.myfoo.tests"]
end

Or, modify the test project build to move the output to a common folder so you can collect the test assemblies from there.

msbuild :build_tests do |msb|
  # ... all your other configuration ...
  msb.properties = { 
    :outputpath => (File.expand_path "bin/Tests/Release")
  }
end

nunit :test => [:build_tests] do |nunit|
  nunit.command = "whatever.exe"
  nunit.assemblies = FileList["bin/Tests/Release/*.tests.dll"]
end

In the end, I think you have some bigger problems. Why aren't your test assemblies building with your main solution/project? Solve that problem and then they'll be in the output path. Try to assign a single, global output path so that all your stuff is in one place (and you don't have to search). And, more importantly, what are all these other tests projects in your solution? Why aren't they being run? Sounds like maybe you have more than one logical program in the solution and maybe they need to be split up.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top