为什么这个注释掉的 MSpec Behaviour 会出现在 ReSharper 测试运行程序中?

发布于 2024-12-17 10:20:45 字数 1039 浏览 2 评论 0原文

MSpec 大师,为什么这不起作用?

public class with_command_line_args {
    protected const string ValidFilename = "ValidFilename.txt";
    protected const string InvalidFilename = "Invalid:Filename";
    protected static  string[] Args;
    protected static Exception Exception;
}

[Behaviors]
public class InvalidCommandlineArgsBehaviours
{
    protected static Exception Exception;
    It should_throw= () => Exception.ShouldNotBeNull();
    //It should_not_store_any_filename;
}

[Subject(typeof(Program), "Invalid command line parameter")]
public class when_invoked_with_no_parameters : with_command_line_args
{
    Establish context = () => Args = new string[] {};
    Because of = () => Exception = Catch.Exception(() => Program.ProcessCommandLineArgs(Args));
    Behaves_like<InvalidCommandlineArgsBehaviours> invalid_args;
}

当我在 ReSharper 中运行它时,规范显示但不执行(我也无法调试它):
ReSharper 单元测试运行程序输出
奇怪的是,注释掉的规范出现在 ReSharper 输出中。呃?显然我做的不对,请赐教!

MSpec gurus, why doesn't this work?

public class with_command_line_args {
    protected const string ValidFilename = "ValidFilename.txt";
    protected const string InvalidFilename = "Invalid:Filename";
    protected static  string[] Args;
    protected static Exception Exception;
}

[Behaviors]
public class InvalidCommandlineArgsBehaviours
{
    protected static Exception Exception;
    It should_throw= () => Exception.ShouldNotBeNull();
    //It should_not_store_any_filename;
}

[Subject(typeof(Program), "Invalid command line parameter")]
public class when_invoked_with_no_parameters : with_command_line_args
{
    Establish context = () => Args = new string[] {};
    Because of = () => Exception = Catch.Exception(() => Program.ProcessCommandLineArgs(Args));
    Behaves_like<InvalidCommandlineArgsBehaviours> invalid_args;
}

When i run this in ReSharper, the specification shows up but doesn't execute (I can't debug it either):
ReSharper Unit Test Runner output
Curiously, the commented-out specification shows up in the ReSharper output. Eh? Clearly I'm not doing something right, please enlighten me!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

她说她爱他 2024-12-24 10:20:45

啊,这肯定是 ReSharper 的一个奇怪的事情。从 Visual Studio 退出并重新运行上下文后,它按预期工作。
ReSharper 测试运行程序输出

Ah, this must have been a wierd ReSharper thing. After quitting from Visual Studio and re-running the context, it works as expected.
ReSharper test Runner output

梦里寻她 2024-12-24 10:20:45

这对我来说是一个持续存在的问题。有时重新启动 Visual Studio 可以解决该问题。有时会重命名行为。有时只需注释掉行为中的测试,然后一一重新启用它们!
我尝试升级 Machine.Specifications ReSharper 插件但无济于事。

现在,无论我尝试什么,我都无法在 R# 测试运行程序中可靠地运行一种行为...

我真的很感谢提供的任何帮助!

ReSharper 6.1.1000.82
机器规格0.5.6
视觉工作室2010

This is a constant problem for me. Sometimes restarting Visual Studio resolves it. Sometimes renaming the behaviour. Sometimes just commenting out the tests in the behaviour and then re-enabling them one by one!
I've tried upgrading the Machine.Specifications ReSharper plug-in to no avail.

Right now I have one behaviour that I can't get to reliably run in the R# test runner no matter what I try...

I'd really appreciate any help offered!

ReSharper 6.1.1000.82
Machine.Specifications 0.5.6
Visual Studio 2010

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文