gpt4 book ai didi

integration-testing - 为什么这个简单的 MSpec 测试返回不确定?

转载 作者:行者123 更新时间:2023-12-04 00:12:42 25 4
gpt4 key购买 nike

我正在将 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();
}

最佳答案

machine.specifications.runner.resharper runner 是 ReSharper 的一个版本。以后最好等到 runner 有时间 catch 兼容性再升级 ReSharper。

关于integration-testing - 为什么这个简单的 MSpec 测试返回不确定?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30216933/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com