1

Using .net core 3.1, I added an xunit project to a solution with the following test class:

using System.Collections.Generic;
using Xunit;

namespace BP
{
    public class BreakPointFails
    {
        public static IEnumerable<object[]> GetData
        {
            get
            { // <------- VS never hits this breakpoint
                return new List<object[]>
                {
                    new object[] { "name", "Bill" },
                    new object[] { "name", "Paul" },
                    new object[] { "name", "Steve" }

                };
            }
        }
        [Theory]
        [MemberData("GetData")]
        public void ExtractScopeStringTest(string name, string lastName)
        {
            Assert.True(name != lastName);
        }
    }
}

If I mark a breakpoint at line with the comment "<------- VS never hits this breakpoint", VS debugger never stops at that line. Breakpoints anywhere else worke fine, but the in the methods pointed by [MemberData] attribute.

I am emphesising that the debug seup is fine and breakpoints anywhere in the test methods work perfect except methods pointed by [MemberData].

Why is that?

Update 1: Line with the breakpoint comment in the code above is juts to indicate a VS breakpoint to be added. The Markdown doesn't allow me to show a breakpoint red dot in the question.

Allan Xu
  • 7,998
  • 11
  • 51
  • 122
  • Why do you need to set breakpoints at line with the comment ? Visual Studio Xunit console runner creates AppDomain with test data for 'MemberData', so the data will be saved in memory after build. – Xingyu Zhao Aug 21 '20 at 09:16
  • @XingyuZhao, Line with the breakpoint comment in the code above is juts to indicate a VS breakpoint to be added. The Markdown doesn't allow me to show a breakpoint red dot in the question. – Allan Xu Aug 21 '20 at 13:32
  • Could you provide more details about 'Markdown'? I can see my breakpoint dot in my Visual Studio. – Xingyu Zhao Aug 24 '20 at 05:55
  • 1
    @XingyuZhao, any breakpoint insie the meber that MemberData is pointing won't work. In my example, any breakpoint inside GetData->Get won't work. – Allan Xu Aug 24 '20 at 13:47

0 Answers0