I have an xUnit project that has run all tests flawlessly until now.
I added two new test methods and now, suddenly, no tests can run because an exception is thrown:
System.Collections.Generic.KeyNotFoundException: Unable to find UniqueTest VSTestAdapter
Followed by a path to one of my test method, but sometimes when I, still, try to run all tests the method after the exception changes.
The kind of the exception leads me to think maybe the following code is related to the problem, but all tests ran fine after I wrote it, the problem appeared after I wrote two quite ordinary tests and commenting them does nothing.
The suspect code:
public static IEnumerable<object[]> TestData
{
get
{
return new[]
{
new object[] { "zrgrgffwf", new string[] { "sf", "age", "fe"} },
new object[] { "gfsefsefse", new List<string>() { "fef", "awr", "hrg" } },
new object[] { "shgfeswff", new HashSet<string>() { "shsg", "wde", "kiuik" } },
new object[] { "pajfoehgsd", new Queue<string>(new string[] { "okd", "rnop", "rng" }) }
};
}
}
As I said, after adding that and using it in a MemberData
attribute property everything ran fine several times. The problem appeared after I wrote this:
[Theory]
[InlineData("sample text", "lolwut", "test")]
[InlineData("other sample text", "yup", "ahha")]
[InlineData("yadda", "-", "yadda.")]
[InlineData("et", "cete", "ra")]
public void Method_Test(string testString, string testCase, string expected)
{
string actual = testedMethod(testCase);
Assert.Equal(expected, actual);
}
Additional note: I had the same exception happen before once after writing that property code, when trying to "Run all" tests in "Release" configuration. But just clicking "Run all tests" again and/or switching to "Debug" seemed to fix it - all tests ran. Now I made sure to be in "Debug" but no matter how many times I click "Run all tests" the only thing that sometimes changes is, like I said, the method cited after the exception.