为什么这个注释掉了MSpec Behavior出现在ReSharper测试运行器中?

时间:2011-11-21 19:56:28

标签: c# unit-testing bdd behavior mspec

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 Unit Test Runner output
奇怪的是,注释掉的规范显示在ReSharper输出中。嗯?显然我没有做对,请赐教!

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

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

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

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

ReSharper 6.1.1000.82 机器。规格0.5.6 Visual Studio 2010