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 输出中。诶?显然我做的不对,请赐教!

4

2 回答 2

1

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

于 2011-11-21T20:13:50.700 回答
0

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

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

我非常感谢提供的任何帮助!

ReSharper 6.1.1000.82 Machine.Specifications 0.5.6 Visual Studio 2010

于 2012-05-31T13:12:15.053 回答