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

Notification

Icon
Error

Ncrunch test not working for me
vikram
#1 Posted : Tuesday, December 23, 2025 9:56:05 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/23/2025(UTC)
Posts: 2
Location: India

Hi i am running simplest test to evaluate Ncrunch for my application, unable to use it. I am using simplest sample code

created console app
namespace ConsoleApp6
{
// Simple calculator class to add two integers
public class Adder
{
public int Add(int a, int b)
{
return a + b;
}
}

internal class Program
{
static void Main(string[] args)
{
var adder = new Adder();
int result = adder.Add(2, 3);
Console.WriteLine("Result: " + result);


}
}
}


unit test
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ConsoleApp6; // add this

namespace UnitTestProject1
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void Add_TwoAndThree_ReturnsFive()
{
// arrange
var adder = new Adder();

// act
var result = adder.Add(2, 3);

// assert
Assert.AreEqual(5, result);
}
}
}

error in ncrunch
The 'Restrict ToString usage to avoid side-effects' setting is currently enabled for this solution.

When this setting is enabled, NCrunch will take an extremely cautious approach to calling the 'ToString' method on objects that are collected by RDI, potentially losing the opportunity to capture and report more useful information about these objects.

When first using RDI on a solution, a cautious approach is recommended because 'ToString' methods can sometimes contain side-effects that can change the behaviour of code being executed by NCrunch. As RDI calls these methods extensively, this can result in tests failing without obvious reason or explanation.

If your codebase is stable with RDI, it is recommended you try disabling this setting for a better experience with NCrunch.

When writing 'ToString' methods, ensure the code in these methods does not change the state of objects involved. If you encounter problems with 'ToString' methods implemented on system types or widely used frameworks, please report this to the NCrunch development team via the bug reporter, as we maintain a built-in list of types to exclude from RDI by default.

Click here to hide this warning


no test cases is run its ignored
vikram
#2 Posted : Tuesday, December 23, 2025 10:06:25 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/23/2025(UTC)
Posts: 2
Location: India

worked for me

In Visual Studio, open the NCrunch menu.
Choose Configuration.
Switch to the Solution configuration (you can also change it at Global if you want the default for all solutions).
Use the search box to find “Restrict ToString usage to avoid side-effects”.
Set it to False (or uncheck it).
Stop and start the NCrunch engine to apply the change.
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.037 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download