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

Notification

Icon
Error

NCrunch 1.48.0.5 and Visual Studio 2013 failing tests
Belinda
#1 Posted : Monday, November 25, 2013 10:38:25 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 11/25/2013(UTC)
Posts: 2
Location: Australia

Thanks: 1 times
Hi,

In a project I am working on we have a suite of tests that currently pass when run with NCrunch (1.44.0.11) on VS2012. However when I attempt to run the tests using NCrunch (1.48.0.5) with VS2013 a number of them fail. The failing tests are quite old legacy tests and are situated in our web project. I have done some digging around and looked in the bin folder of the NCrunch compilation and discovered that the ncrunchconfig file that is created for the 2013 version comes from our web.config rather than the app.config (which is where it comes from in the 2012 run). the failure message of all the tests is "System.InvalidOperationException : The ConnectionString property has not been initialized." and clearly those connection strings come from the app.config. Is there some way I can configure NCrunch in 2013 to use the app.config as it had previously be doing? I cant see anything in the NCrunch Configuration settings that would allow me to do that, but perhaps I'm not looking in the right place.

thanks
Remco
#2 Posted : Monday, November 25, 2013 11:28:43 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,980

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi, thanks for posting!

As far as I know, there has been no intentional change in behaviour between 1.44 and 1.48 around the source of this configuration. However, there has been a huge number of fixes for other related problems, so it's entirely possible that the behaviour has been changed to resolve something else. The upgrade to VS2013 in your case may also have introduced different behaviour, as a VS upgrade includes many changes to the MSBuild scripts. There is no configuration setting that controls which config file NCrunch uses for its test environment. Configuration should always originate from the config file which has the same name as the build output assembly, plus '.config'.

With that said, having a web project with two different config files containing tests strikes me as something that is certain to cause you problems. A project should only ever have one configuration file - as to have more would invite configuration loading inconsistencies such as this one. Is there a reason you have two config files? I would probably recommend that you fix this if possible.

One way you may be able to work around the problem is to introduce conditional compilation for the NCrunch test environment, knocking the web.config out of the project file while NCrunch builds it. For example, you'll probably have the following inside your .proj file:

<Content Include="Web.config">
<SubType>Designer</SubType>
</Content>

Try replacing this with the following code:

<Content Include="Web.config" Condition="$(NCrunch) != '1'">
<SubType>Designer</SubType>
</Content>

I haven't tested this, but it may do the trick.


Cheers,

Remco
1 user thanked Remco for this useful post.
Belinda on 11/26/2013(UTC)
Belinda
#3 Posted : Tuesday, November 26, 2013 2:53:33 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 11/25/2013(UTC)
Posts: 2
Location: Australia

Thanks: 1 times
Hi Remco,

thanks for your response. the workaround worked fine but I am also now going to merge our two configs into one so we can avoid this problem in the future. I think the reason we had the separated app.config no longer exists (the code base is about 8 years old so there a lots of sections of deadwood to be removed) so that should be fine.


cheers

Belinda
Remco
#4 Posted : Tuesday, November 26, 2013 2:56:07 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,980

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi Belinda -

Great to hear. I'm sure an 8 year old code base must be full of surprises :) Good luck with the cleanup!


Cheers,

Remco
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.039 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download