Build/Test Issues

Theory with datetime randomly is not being executed (see example)

Started by 10000 on 4,545 views

Hi, the following code sometimes is not being executed, whereas other 500 test are perfectly fine. There aren't any issues with ReSharper runner or with console. Newest versions of NCrunch, Visual Studio 2017 and Xunit are used

Code:

public class DateExtensionsTests
    {
        public static IEnumerable<object[]> Dates => new[]
        {
            new object[] { DateTime.MinValue, false },
            new object[] { default(DateTime), false },
            new object[] { DateTime.MaxValue, false },
            new object[] { DateTime.Now.Subtract(TimeSpan.FromDays(1)),true  }, // fails
            new object[] { DateTime.Now.Subtract(TimeSpan.FromHours(1)), false  }, // fails
            new object[] { DateTime.Now.AddDays(1), false  } // fails
        };

        [Theory, MemberData(nameof(Dates))]
        public void ShouldReturnDeadlineCorrectness(DateTime userSetDate, bool isFromPast)
        {
            userSetDate.IsFromPastExceptDefaultValue().ShouldEqual(isFromPast);
        }
    }


Error 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.

Edited

Hi, thanks for posting!

This use case is not supported under NCrunch. See here for more details.

Edited

Post a reply

Log in to reply.