为什么这个简单的MSpec测试没有结果?

时间:2015-05-13 13:51:49

标签: integration-testing mspec fakeiteasy

我正在使用Mspec和FakeItEasy,我一直在测试结果不确定。我试着评论我的假设置代码,甚至是测试中的方法的实际调用。我也无法调试测试。我也尝试过这样一个简单的测试:

private Then it_should_be_true = () => true.ShouldBeTrue();

不确定测试的原因是什么?

enter image description here

[Tags("IntegrationTest")]
[Subject(typeof(AuthManager))]
public class When_a_login_is_performed_using_valid_credentials
{
    protected static string MemberUsername;
    protected static string MemberPassword;
    protected static SignInResponse Response;

    private Given context = () =>
    {
        MemberUsername = "User1";
        MemberPassword = "Pass1";
    };

    private When test = () =>
    {
        Response = AuthManager.Current.SignIn(MemberUsername, MemberPassword);
    };

    private Then It_should_return_a_successful_response = () => Response.Success.ShouldBeTrue();
    private Then It_should_not_contain_any_reported_errors = () => Response.Errors.ShouldBeEmpty();
    private Then It_should_have_an_Id_populated = () => Response.Id.ShouldNotBeEmpty();
}

我将它包装成Then然后使用下面的代码匹配BDD语法。它一直在使用过。

using Machine.Specifications;

namespace Testing.MachineSpecifications
{
    /// <summary>
    /// Given
    /// </summary>
    [SetupDelegate]
    public delegate void Given();

    /// <summary>
    /// When
    /// </summary>
    [ActDelegate]
    public delegate void When();

    /// <summary>
    /// Then
    /// </summary>
    [AssertDelegate]
    public delegate void Then();
}

1 个答案:

答案 0 :(得分:2)

machine.specifications.runner.resharper亚军是ReSharper背后的一个版本。在未来,等待升级ReSharper,直到跑步者有时间赶上兼容性,这将是一件好事。