CodeRush 18.2.6
Hello, we are using CodeRush test runner and we like to run tests from code editor. There is an issue with the test marked with [Theory] attribute and using [ClassData] or [MemberData].
These tests can be run fromTestRunner, but the button for running the test in Code editor is often missing for tests with [ClassData]. Sometimes is visible but more often is not shown. So these tests can be run only from Test runner.
See screenshots for Test runner and Code editor.
With a simple Class data, (as bellow) the button is always visible.But with complicated (IMO non serializable) data, the button is missing.
C#public class TestXUnit
{
[Theory]
[ClassData(typeof(TestTheoryData))]
private void TestTheory(string test)
{
Assert.NotNull(test);
}
}
public class TestTheoryData : TheoryData<string>
{
public TestTheoryData()
{
Add("1");
Add("2");
}
}
Screenshot with TestRunner
Hi Karel,
Thanks for the attached screenshots and code snippet.
I tried to reproduce this issue in the latest build, but failed. See this screencast.
It would be helpful if you provide us with the problematic project so we can reproduce this issue.
We are looking forward to hearing from you.
I found a cause of this misbehavior. This is caused by the combination of [Theory], private async and [ClassData] . See code example below.
public class TestXUnit { public class TestClassData : TheoryData<string> { public TestClassData() { Add("Test1"); Add("Test2"); } } // private async: icon disappears after execution and reappears after some time [Theory] [InlineData("Test1")] [InlineData("Test2")] private async void TestTheory1(string test) { await Task.CompletedTask; Assert.NotNull(test); } // public async: icon is ok [Theory] [InlineData("Test1")] [InlineData("Test2")] public async void TestTheory2(string test) { await Task.CompletedTask; Assert.NotNull(test); } // private async: icon disappears after execution and never reappears [Theory] [ClassData(typeof(TestClassData))] private async void PrivateTestTheoryClass(string s) { await Task.CompletedTask; Assert.NotNull(s); } // public async: icon is ok [Theory] [ClassData(typeof(TestClassData))] public async void PublicTestTheoryClass(string s) { await Task.CompletedTask; Assert.NotNull(s); } // works ok [Fact] private async void FactTest1() { } }
Hi Karel,
Thank you for the code snippet.
I tried to reproduce this misbehavior with you code in the attached project, but failed. I demonstrated my steps in this screencast. Are they correct for reproducing this problem?
It would be helpful if you provide us with a screencast illustrating the problem in action. For instance, you can capture it using the free Monosnap tool.
In addition, please provide your CodeRush Logs. This would help us determinate the cause of the problem.
Follow these steps to get to the CodeRush Logs folder:
It seems that the key is Net.Core project. I have extracted your project, run tests and icons does not disappear.
Whereas the same code in my Net.Core test project causes the icon disappears. Screencast follows.
Screencast
Logs
Thank you for the logs and screencast. We have reproduced the issue with the .Nat Core test project. We will investigate this problem and will let you know once we have any progress.