With Instrumentation Mode set to Optimized I'm seeing MSpec behaviors with generic types fail when instrumented with a custom type (though not with .NET types such as Object or String). After changing the instrumentation mode to Legacy everything works as expected.
Requirements:
Latest Machine.Specifications and Machine.Specification.Should NuGet packages.
NCrunch instrumentation mode set to Optimized.
Code:
// Everything works as expected for this test (one test passes and one test fails)
public class when_concrete_type_is_string : TestBehavior<String> {
Establish context = () => {
Console.Out.WriteLine("Context ran.");
};
Behaves_like<TestBehavior<String>> a_test_object = () => { };
}
// Both tests fail with this message:
// This test was not executed during a planned execution run.
// Ensure your test project is stable and does not contain issues in initialisation/teardown fixtures.
public class when_concrete_type_is_test_object : TestBehavior<TestObject> {
Establish context = () => {
Console.Out.WriteLine("Context ran.");
};
Behaves_like<TestBehavior<TestObject>> a_test_object = () => { };
}
[Behaviors]
public class TestBehavior<T> {
It should_run_passing_test = () => {
true.ShouldBeTrue();
};
It should_run_failing_test = () => {
false.ShouldBeTrue();
};
}
public class TestObject {
}
Let me know if you need me to gather any additional information for you.