MSpec Resharper Test Runner not displaying results for behaviors with generic types #128

Closed
MattRyan opened this Issue Jan 22, 2013 · 6 comments

Comments

Projects
None yet
2 participants

When I create behaviors with generic types the Re# test runner does not display the test results. When the project or solution is first loaded the tests appear correctly. However if I modify the behavior class or create a new generic behavior then the tests begin resulting in "Inconclusive: Test wasn't run" messages. This state will continue until Visual Studio is restarted. The MSpec runner does not experience these issues.

Thanks,
Matt

Visual Studio 2010
Resharper 7.1.1000.900

Example Code:

[Behaviors]
public class ExpectedExceptionBehavior<TException> 
    where TException : Exception
{
    protected static Exception ExpectedException;

    It should_throw_an_exception = () => ExpectedException.ShouldNotBeNull();

    It should_be_of_expected_type = () => ExpectedException.ShouldBeOfType<TException>();
}

public class When_an_exception_is_thrown
{
    private Establish context = () => {};

    private Because of = () =>
        {
            ExpectedException = Catch.Exception(() =>
                {
                    throw new Exception();
                });
        };

    protected static Exception ExpectedException;

    Behaves_like<ExpectedExceptionBehavior<Exception>> an_exception; 
}
Owner

agross commented Jan 23, 2013

This is likely due to caching. Thanks for the report, I'll look into it.

Owner

agross commented Jan 23, 2013

Please test the ReSharper runner bundled with mspec-0.5.11-beta7 (available on NuGet).

I have tested with mspec-0.5.11-beta7 and the problem is fixed but replaced with a new problem. When I change the name of the behavior and run the tests the unit test session empties. If I run the test again the test results appear as they should.

@MattRyan MattRyan closed this Jan 23, 2013

@MattRyan MattRyan reopened this Jan 23, 2013

Owner

agross commented Jan 23, 2013

By "emptying the session" you mean that only the behavior was in the
current session?

I. e. behavior (behaves like and everything below) gets removed and then
re-added when you run tests this next time.

Alex

Alexander Groß
Tiny phone, tiny mail
On Jan 23, 2013 8:25 PM, "MattRyan" notifications@github.com wrote:

I have tested with mspec-0.5.11-beta7 and the problem is fixed but
replaced with a new problem. When I change the name of the behavior and run
the tests the unit test session empties. If I run the test again the test
results appear as they should.


Reply to this email directly or view it on GitHubhttps://github.com/machine/machine.specifications/issues/128#issuecomment-12617206.

To clarify it is all the MSpec tests in the current session.

I am also noticing that some tests appear in the test runner with the message "behave like ..." struck out. Running the test again causes the test to appear along side the struck out test.

Additionally other tests' subject will disappear and will not reappear on subsequent runs. If you double click on the test it will navigate to the source but the test will be removed from the unit test session. Running the test after this repairs the subject and the double click navigation. Manually deleting test in this state will not fix the issue.

Owner

agross commented Feb 1, 2013

Matt, please test 0.5.11-beta8. It hopefully fixes everything regarding behaviors.

@kropp told me that when you rename "container" elements (contexts, behaviors) they will be removed from the unit test session and that this is expected behavior. So, if you rename a behavior (Behaves_like field) it will only be readded to the session if you run the whole context.

@agross agross closed this in faf2f71 Feb 13, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment