0

So, I am working on a C# project to add unit tests to an existing, very large solution, without previous tests. The design for this is to add a unit test project to the existing solution, referencing the existing project in order to carry out the test logic.

In terms of compiling and running the tests, as I only ever actually update and change my tests as part of this work, I would like to only build and run the test project without rebuilding the large underlying project, which Visual Studio seems to do regardless of whether anything in the original project has changed.

From what I've been able to glean from online, there are options in VS to limit what is actually compiled apart from dependencies, though applying these have made no difference.

EG: Visual Studio 2008 Unnecessary Project Building (Different version of VS, but concept is the same)

Is there a way to build and run tests in this way, or is is it simply that VS will always rebuild any referenced projects?

P.Wright
  • 71
  • 5
  • But visual studio will automatically build other projects before running the unit test. Why do you want to run the unit test without building the dependent projects? – Keyur Ramoliya Oct 05 '18 at 16:02
  • Why not create a new build configuration where the main project is not built? https://learn.microsoft.com/en-us/visualstudio/ide/understanding-build-configurations?view=vs-2017 – Kami Oct 05 '18 at 16:08
  • Honestly, the dependent projects are taking about 20-30 minutes to build, which is making it take a very long time to write and test my tests. I've tried toubleshooting the build process as well, but I haven't been able to identify any reason the dependency has been so slow to build aside from it's sheer size; which is something else I'm currently looking at. In theory if I've not changed anything in the dependency, I don't see why I should need to rebuild it to run a suite of tests against it, so hoping to sidestep this, at least long enough to get some testing set up. – P.Wright Oct 05 '18 at 16:11
  • @P.Wright just reference the DLL in the bin folder instead. don't include the project or else it will try to run the latest code every time. – Franck Oct 05 '18 at 16:12
  • @Kami Thanks, that'll at least work for now while I'm just writing my tests, though I'll probably want to look into something like Franck suggested below for a more long-term solution – P.Wright Oct 05 '18 at 16:20

0 Answers0