如何在 Resharper 4.5 中使用 bdd 命名样式?
我刚刚升级到 Resharper 4.5,现在看到我所有的 BDDish 测试方法都被标记为不符合命名标准。 我的命名约定是这样的:
public void Something_ShouldHaveThisResult()
Resharper 不喜欢方法中的下划线。 有没有办法关闭它,仅用于测试方法? 我对其余代码有正常的命名约定。
I just upgraded to Resharper 4.5 and now see that all my BDDish test methods are marked as not conforming to the naming standard. My naming convention is like this:
public void Something_ShouldHaveThisResult()
Resharper doesn't like the underscore in the method. Is there a way to turn this off, just for test methods? I have a normal naming convention for the rest of my code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
如何更改测试方法的 ReSharper 命名样式
How to change the ReSharper naming style for test methods
如果您想使用非测试代码源遵循 Microsoft 风格指南 - 您是否尝试过使用 StyleCop for ReSharper 插件?
正如之前建议的:禁用内部 ReSharper 命名规则集或切换检查设置。 StyleCop(即 StyleCop ReSharper 插件)允许继承解决方案文件夹结构中的 Settings.StyleCop 文件。 因此,您可以检查“真实”源中的有效名称,同时禁用测试代码的分析。
If you want to follow the Microsoft style guide with your non-test code sources - Have you tried using the StyleCop for ReSharper plugin?
As recommended before: disable the internal ReSharper naming rule set or toggle the inspection settings. StyleCop (thus the StyleCop ReSharper plugin) allows inheritance over the Settings.StyleCop files in your solution folder structure. So you are able to check for valid names in the "real" sources, while the analysis of the test code is disabled.
您可以
使用// ReSharper disable InconcientNaming
// ReSharper Restore InconcientNaming
在每个类的末端 。 例如,
但这将删除所有命名警告,而不仅仅是方法名称上的警告。
You could use
// ReSharper disable InconsistentNaming
// ReSharper restore InconsistentNaming
around the extremities of each class. e.g
This however will remove all naming warnings, and not just those on the Method name(s).
我已经在 ReSharper 错误跟踪器中添加了对此的请求。 您可以投票。
I've already added a request for this in the ReSharper bug-tracker. You can vote for it.
Resharper 4.5.1 添加了此功能。 您现在可以添加专门应用于测试方法的新自定义命名规则,并允许其包含下划线。
Resharper 4.5.1 has added this capability. You can now add a new custom naming rule that applies specifically to a test method, and allow it to contain underscores.
您可以使用 Agent Smith 获得更精确的代码命名约定。
注意:最终的 R# 4.5 版本似乎尚未编译……但我确信它很快就会出现。
You can use Agent Smith for more precise code naming conventions.
Note: the version for the final R# 4.5 seems not to be compiled yet... but I'm sure it will be there soon.
无需删除规则。 可以添加接受下划线的新
规则 选项-> 语言 -> 常见-> 命名样式并在底部“用户定义的命名规则”添加新规则
There is no need to remove rules. New Rule can be added that accept underscores
Resharper | Options -> Languages -> Common -> Naming Style and add new rule to the bottom "User defined naming rules"
菜单上:
Reshaper | 选项-> 语言 -> 常见-> 命名风格:删除您想要的命名风格。 他们应该有一个“禁用”功能,但他们没有。
On the menu:
Resharper | Options -> Languages -> Common -> Naming Style: remove what ever naming style you want. They should have a "disable" feature, but they don't.