Build/Test Issues

With optimized instrumentation generic MSpec behavior fails with "This test was not executed..."

Started by ljohnston on 2,559 views

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.


// 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.
Hi,

Thanks for sharing this problem. I've managed to reproduce it exactly as described.

We'll take a look and will update you when a fix is available.
Hi,

Would you mind trying the build below:

NCrunch_Console_4.4.0.6.msi
NCrunch_Console_4.4.0.6.zip
NCrunch_GridNodeServer_4.4.0.6.msi
NCrunch_GridNodeServer_4.4.0.6.zip
NCrunch_LicenseServer_4.4.0.6.zip
NCrunch_VS2008_4.4.0.6.msi
NCrunch_VS2010_4.4.0.6.msi
NCrunch_VS2010_4.4.0.6.zip
NCrunch_VS2012_4.4.0.6.msi
NCrunch_VS2012_4.4.0.6.zip
NCrunch_VS2013_4.4.0.6.msi
NCrunch_VS2013_4.4.0.6.zip
NCrunch_VS2015_4.4.0.6.msi
NCrunch_VS2015_4.4.0.6.msi.7z
NCrunch_VS2015_4.4.0.6.zip
NCrunch_VS2017_4.4.0.6.msi
NCrunch_VS2017_4.4.0.6.msi.7z
NCrunch_VS2017_4.4.0.6.zip
NCrunch_VS2019_4.4.0.6.msi
NCrunch_VS2019_4.4.0.6.msi.7z
NCrunch_VS2019_4.4.0.6.zip
Hi,

Thanks for working on this.

This fixed behaviors with one generic argument, but behaviors with two generic arguments are still broken (I haven't tried more than two). This can be reproduced using the code in the original post by changing TestBehavior<T> to TestBehavior<T, U> and passing the same type a second time everywhere it's used (e.g. TestBehavior<TestObject, TestObject>). The error message is the same.
ljohnston wrote:
This fixed behaviors with one generic argument, but behaviors with two generic arguments are still broken (I haven't tried more than two). This can be reproduced using the code in the original post by changing TestBehavior<T> to TestBehavior<T, U> and passing the same type a second time everywhere it's used (e.g. TestBehavior<TestObject, TestObject>). The error message is the same.


Thanks for picking this up. We'll see if we can get it fixed.
ljohnston wrote:
This fixed behaviors with one generic argument, but behaviors with two generic arguments are still broken (I haven't tried more than two). This can be reproduced using the code in the original post by changing TestBehavior<T> to TestBehavior<T, U> and passing the same type a second time everywhere it's used (e.g. TestBehavior<TestObject, TestObject>). The error message is the same.


I'm having some trouble reproducing this as you've described. It seems to work correctly for me. Is there any chance you can share a code sample with me?
Sorry about the delay, I didn't get a notification for your latest reply (I think I must have viewed the previous one without logging in/using the link from the email).

Here's an updated sample (which appears to fail in the same way as the previous one did):

// Everything works as expected for this test (one test passes and one test fails)
public class when_concrete_type_is_string : TestBehavior<String, String> {

    Establish context = () => {
        Console.Out.WriteLine("Context ran.");
    };
 
    Behaves_like<TestBehavior<String, 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, TestObject> {

    Establish context = () => {
        Console.Out.WriteLine("Context ran.");
    };

    Behaves_like<TestBehavior<TestObject, TestObject>> a_test_object = () => { };
}

[Behaviors]
public class TestBehavior<T, U> {

    It should_run_passing_test = () => {
        true.ShouldBeTrue();
    };

    It should_run_failing_test = () => {
        false.ShouldBeTrue();
    };

}

public class TestObject { 
}

Edited

Thanks for the sample. That did it for me (red across the board).

I'll let you know as soon as we have a fix available.
Could you try the build below and confirm whether this solves the issue for you?

NCrunch_Console_4.4.0.7.msi
NCrunch_Console_4.4.0.7.zip
NCrunch_GridNodeServer_4.4.0.7.msi
NCrunch_GridNodeServer_4.4.0.7.zip
NCrunch_LicenseServer_4.4.0.7.zip
NCrunch_VS2008_4.4.0.7.msi
NCrunch_VS2010_4.4.0.7.msi
NCrunch_VS2010_4.4.0.7.zip
NCrunch_VS2012_4.4.0.7.msi
NCrunch_VS2012_4.4.0.7.zip
NCrunch_VS2013_4.4.0.7.msi
NCrunch_VS2013_4.4.0.7.zip
NCrunch_VS2015_4.4.0.7.msi
NCrunch_VS2015_4.4.0.7.msi.7z
NCrunch_VS2015_4.4.0.7.zip
NCrunch_VS2017_4.4.0.7.msi
NCrunch_VS2017_4.4.0.7.msi.7z
NCrunch_VS2017_4.4.0.7.zip
NCrunch_VS2019_4.4.0.7.msi
NCrunch_VS2019_4.4.0.7.msi.7z
NCrunch_VS2019_4.4.0.7.zip
All our behaviors are behaving as expected now. Thanks!

Post a reply

Log in to reply.