I'm using FluentAssertions 5.3.0 run under NCrunch 3.14.0.1. When a test fails, I often seen this error as FluentAssertions tries to generate a report message...
System.ArgumentOutOfRangeException: startIndex cannot be larger than length of string. Parameter name: startIndex at System.String.Substring(Int32 startIndex, Int32 length) at FluentAssertions.CallerIdentifier.ExtractVariableNameFrom(StackFrame frame) at FluentAssertions.CallerIdentifier.DetermineCallerIdentity() at FluentAssertions.Execution.AssertionScope.GetIdentifier() at FluentAssertions.Execution.AssertionScope.FailWith(String message, Object[] args) at FluentAssertions.Numeric.NumericAssertions`1.Be(T expected, String because, Object[] becauseArgs) at TableTests.ConsolidatedMovementsTester.AlternativingMovementStatesAreRecognised() in ...test.cs
The error is sporadic - often it will disappear if the test is rerun (in which case, a proper error report is shown). I've seen this in the last couple of versions of both FluentAssertions and NCrunch and it appears on multiple machines (all running some flavour of Visual Studio 2017 Professional).
Here's an example of the latest call to bite me...
results.Count(c => c.IsStationary).Should().Be(5);
where results is an ImmutableArray of POCOs
In this case, right-clicking on the failing test and selecting "rerun in new test runner" in the ncrunch window, caused the test to re-run and FA to emit the correct report.
Can anyone suggest a workaround for this?