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

Notification

Icon
Error

Constants are not covered/tested even though there are tests for them?
Noctis
#1 Posted : Tuesday, January 22, 2013 12:33:15 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/22/2013(UTC)
Posts: 3
Location: Australia

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
Have a class A, and a Test for it:


Code:
class A() {
   public const string foo = "bar";
   public int int_prop{ get { return 7; }}
}

[Test]
public void check_const() {
   A a = new A();
   Assert.AreEqual(a.foo, "bar");
}


Now, i get a black dot on the left of the int_prop (but nothing on the public string).
My test passes. all are happy.

One day, the big scary troll changes my "foo" constant, and it now reads:
public const string foo = "trolled";

If I manually run my tests from Nunit, the check_const() fails miserably (like it should).
BUT ... NCrunch will still show me the green bar reassuring me everything is ok ... (which leads me to suspect that it's on the troll's pay role)

Ideas? suggestions?
Noctis
#2 Posted : Tuesday, January 22, 2013 12:41:03 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/22/2013(UTC)
Posts: 3
Location: Australia

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
Err ... this is bizzare ...

So, I changed my code back (in our example: foo ="bar"; where it used to be foo="trolled"), and was about to go on with my work ...
Now my Nunit tests are all green and happy ... but ... now Ncrunch is showing me a red bar ...
and complaining that check_const fails because "trolled != bar".

Feels like ncrunch is lagging behind and is running an outdated version of my code... tried saving, modifying, but it's still red (even though code wise, it should pass the test, and Nunit tests pass).
Remco
#3 Posted : Tuesday, January 22, 2013 2:12:57 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi, thanks for posting!

NCrunch won't show markers next to constants, as they aren't represented in the debug information for an assembly. Constants are handled very differently by the compiler (vs normal source code). You'll notice that it isn't possible to set a breakpoint on a constant value - at least, not one that will work. NCrunch is also impacted by this constraint.

When NCrunch shows you the incorrect results for the test (i.e. the markers are red when they should be green, or vice versa), are the markers fully coloured or faded out? If the markers are faded, this means that the engine is still processing and hasn't yet been able to show results for the latest version of your code. There are things you can do to improve engine response time if the response times seem to lag (refer to the performance tuning guide.

If the above isn't the case, and the markers are showing incorrect results with solid colour, try doing a reset of the engine by enabling/disabling NCrunch or by clicking the 'reset' button in the Tests Window.
1 user thanked Remco for this useful post.
Noctis on 1/22/2013(UTC)
Noctis
#4 Posted : Tuesday, January 22, 2013 11:20:24 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/22/2013(UTC)
Posts: 3
Location: Australia

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
Remco;3567 wrote:
Hi, thanks for posting!

NCrunch won't show markers next to constants, as they aren't represented in the debug information for an assembly. Constants are handled very differently by the compiler (vs normal source code). You'll notice that it isn't possible to set a breakpoint on a constant value - at least, not one that will work. NCrunch is also impacted by this constraint.

When NCrunch shows you the incorrect results for the test (i.e. the markers are red when they should be green, or vice versa), are the markers fully coloured or faded out? If the markers are faded, this means that the engine is still processing and hasn't yet been able to show results for the latest version of your code. There are things you can do to improve engine response time if the response times seem to lag (refer to the performance tuning guide.

If the above isn't the case, and the markers are showing incorrect results with solid colour, try doing a reset of the engine by enabling/disabling NCrunch or by clicking the 'reset' button in the Tests Window.


they were solid ....
i'll give the magic "turn off, turn on" a try next time i see this ugly beast rear it's head :)
1 user thanked Noctis for this useful post.
Remco on 1/23/2013(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.042 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download