Today I got my unit tests to crash in Visual Studio. Right after some refactoring the tests stopped working and the output window contained the following message:
The active Test Run was aborted because the execution process exited unexpectedly. To investigate further, enable local crash dumps either at the machine level or for process vstest.executionengine.x86.exe. Go to more details: http://go.microsoft.com/fwlink/?linkid=232477
Looking closer at my refactoring action I soon noted that the constructors looked odd. Below a simplified replication of the crashing code. Can you fix the code below?
[TestMethod] public void IsWorking_DefaultConstructor_True() { var testObject = new ClassUnderTest(); var result = testObject.IsWorking(); Assert.IsTrue(result); } public class ClassUnderTest { private object SomeObject; // existing constructor without parameters public ClassUnderTest() : this(Environment.OSVersion) { SomeObject = Environment.OSVersion; } // new constructor added public ClassUnderTest(object someObject) : this() { SomeObject = someObject; } // validate SomeObject is set public virtual bool IsWorking() { return SomeObject != null; } }
* Image courtesy of Stuart Miles / FreeDigitalPhotos.net
Reblogged this on Dinesh Ram Kali..
Your constructors reference one another. Wouldn’t you be finding yourself in an infinite constructor loop?
That was the problem causing the Text Runner to crash. The new constructor should have looked like this
public ClassUnderTest(object someObject)
: this(){SomeObject = someObject;
}