Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

How does NCrunch determine what to put in the output location it uses to run the tests?
samholder
#1 Posted : Friday, May 11, 2012 2:40:30 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 5/11/2012(UTC)
Posts: 94

Thanks: 28 times
Was thanked: 12 time(s) in 12 post(s)
Does NCrunch use the .csproj file to determine how to build the project? I ask because I have a custom post build task which I use to make the config files for the tests different based on the current build configuration, and this custom build task does not seem to be being run by NCRunch (it always seems to use the default configuration file ie the app.config)

This is the post build step I use:

<Target Name="AfterBuild" Condition="Exists('$(ProjectDir)$(Configuration).config')">
<Delete Files="$(TargetDir)$(TargetFileName).config" />
<Copy SourceFiles="$(ProjectDir)$(Configuration).config" DestinationFiles="$(TargetDir)$(TargetFileName).config" />
</Target>

Is there any way I can make NCrunch copy the <configurationName>.config file over the top of the file created from the app.config and then have the tests use that?
Remco
#2 Posted : Saturday, May 12, 2012 12:43:36 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,143

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi Sam -

NCrunch does use the .proj file to establish file dependencies for your projects, although this logic is not sophisticated enough to be able to parse the complex and dynamic dependencies that can exist in pre/post build events.

To solve this problem I would recommend you use the 'Additional files to include' configuration option under the project's NCrunch configuration in order to let NCrunch know about your configuration files. Another option is also to ensure all .config files are included as items in the project, for example:

<Project>
...
<ItemGroup>
<None>MyConfigFile.config</None>
</ItemGroup>
...
</Project>

Also make sure that you enable post build events in your NCrunch project configuration. By default, NCrunch will switch these off as very often pre/post build events contain steps that are not relevant to the test environment. For more information about component configuration, there's page in the wiki - https://www.ncrunch.net/...t-configuration_overview

Note that NCrunch will only ever use the default $(Configuration) that is specified in your .proj file - it doesn't follow the build configuration selected within Visual Studio. There is an NCrunch configuration option that you can use ('Use Build Configuration') against a project to force it to use a specific build configuration if the default doesn't work for you.

I hope this helps!


Cheers,

Remco
samholder
#3 Posted : Monday, May 14, 2012 8:11:21 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 5/11/2012(UTC)
Posts: 94

Thanks: 28 times
Was thanked: 12 time(s) in 12 post(s)
Hi Remco,

Thanks. I was able to get the behaviour I wanted by creating a post build step which replicates the AfterBuild item in the project file.

Thanks! and thanks for an awesome tool!
1 user thanked samholder for this useful post.
Remco on 5/14/2012(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.032 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download