Build/Test Issues

NCrunch ignoring preprocessor, but only for certain projects

Started by Canin on 6,409 views

I'm working on an application extremely heavily dependent on, effectively, data access which while the devs have done a great job abstracting the data access, ever so often something is difficult to test as is due to data access. I've been getting around some of this using preprocessor directives.

Long story short I've encapsulated each of my unit test classes with preprocessor commands of #if UnitTest (which is defined in the properties of each and every project under the solution configuration of "UNITTEST"), alongside anything I need to add into methods to make them testable. However while NCrunch runs the unit tests without issue (again, which are all under #if UnitTest/#endif), it seems to flat out ignore any #if UnitTest found in one project, even if Visual Studio acts on them.

I've verified numerous times that NCrunch Configuration for the project in question (as well as every other project in the solution) are using the build configuration of "UNITTEST," but to no avail.

Long story even shorter: It works for Visual Studio 2010, but not NCrunch, and the only NCrunch setting I can think of seems to be set correctly.

Any pointers as to what I might be doing incorrectly?
In theory, setting the 'Use build configuration' to 'UNITTEST' for each of your projects should solve your problem - though as you've described it sounds as though something more complicated is going on.

Would you be able to show me an extract of the XML from one of your project files showing the main PropertyGroup declarations for the different build configurations you have available? Of particular interest is the manner in which the "DefineConstants" property is being declared between these configurations.

It may also be worth trying to make a build-breaking change to one of the property group items for your 'UNITTEST' configuration, just to confirm whether or not NCrunch is actually using this configuration at all.

Edited

This post has been deleted.

Post a reply

Log in to reply.