Breakpoint in subject code causes unit test to abort without stacktrace (Mono/Rider)

124 views Asked by At

I'm working on a Linux vm with Rider trying to fix unit tests that were ported over into this new environment (previously Windows w/VS). I'm having problems with debugging. Wherever there is a mock instance in a test, if I place a breakpoint anywhere in the subject code where the thing that is mocked is referenced, running the test in debug mode causes the test to abort with no stack-trace.

Rider reports:

=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

Here's complete code from a test file I'm writing just to isolate the problem.
Important notes in comments:

using NUnit.Framework;
using Moq;

namespace UnitTests
{
    [TestFixture]
    public class TestDebugging
    {
        private Mock<MockableThing> _testMock;

        [SetUp]
        public void SetUp()
        {
            _testMock = new Mock<MockableThing>();
        }

        [Test]
        public void TestMe()
        {  
            _testMock.Setup(m => m.GetSomething()).Returns("mock thingy.");

            var sut = new Subject(_testMock.Object);   

            //breakpoint here will work in debug mode, but stepping 
            //into the call causes the test to abort.             
            var something = sut.SaySomething();
            Assert.IsTrue(true);
        }

        public class Subject
        {
            private MockableThing _thing;

            public Subject(MockableThing thing)
            {
                //Placing a breakpoint here and running in debug mode
                //causes the test to abort.
                _thing = thing;
            }

            public string SaySomething()
            {
                return _thing?.GetSomething();
            }
        }

        public class MockableThing
        {
            public string Id { get; set; }
            public virtual string GetSomething()
            {
                return "this shouldn't be returned because it is mocked.";
            }
        }
    }
}

Can anyone provide insight that could lead to a full fix for this issue?

0

There are 0 answers