为什么这个简单的 MSpec 测试 return 没有结论?
Why does this simple MSpec test return inconclusive?
我正在将 Mspec 与 FakeItEasy 结合使用,但我不断收到不确定的测试结果。我尝试注释掉我的假设置代码,甚至注释掉被测方法的实际调用。我也无法调试测试。我也刚刚尝试了这样一个简单的测试:
private Then it_should_be_true = () => true.ShouldBeTrue();
测试不确定的原因是什么?
[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();
}
machine.specifications.runner.resharper 运行程序比 ReSharper 落后一个版本。以后还是等跑者有时间赶上兼容性再升级ReSharper就好了。
我正在将 Mspec 与 FakeItEasy 结合使用,但我不断收到不确定的测试结果。我尝试注释掉我的假设置代码,甚至注释掉被测方法的实际调用。我也无法调试测试。我也刚刚尝试了这样一个简单的测试:
private Then it_should_be_true = () => true.ShouldBeTrue();
测试不确定的原因是什么?
[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();
}
machine.specifications.runner.resharper 运行程序比 ReSharper 落后一个版本。以后还是等跑者有时间赶上兼容性再升级ReSharper就好了。