Visual Studio 2012单元测试:控制器必须设置可测试的元素属性(Visual Studio 2012 Unit Testing: Controller must have testabl

编程入门 行业动态 更新时间:2024-10-22 18:50:55
Visual Studio 2012单元测试:控制器必须设置可测试的元素属性(Visual Studio 2012 Unit Testing: Controller must have testable element property set up)

我试图使用Visual Studio的单元测试生成功能。 我发现的第一件事是这个扩展 ,但由于某种原因,它不起作用 - 即使在重新启动后,虽然我可以验证扩展已安装,但“生成单元测试”不显示在上下文菜单中,点击一个方法。

接下来我尝试的是在其中一条评论中找到的解决方法 - 显然原始特征仍然存在,只是被埋没了。 解决方法是:

工具 - >选项 环境 - >键盘 显示包含'unit'的命令 附加一个“ EditorContextMenus.CodeWindow.CreateUnitTests ”的快捷方式。

但是,这也行不通,因为似乎没有任何事情发生。 还有两个可能相关的其他命令 - EditorContextMenus.CodeWindow.GenerateUnitTests和Project.AddUnitTest 。 这两种工作都不起作用 - 后者只是无所作为,前者给了我错误“控制器必须设置可测试元素属性”。

所以......我不太确定还有什么可以尝试的。

I'm trying to use Visual Studio's unit test generation feature. The first thing I found was this extension, but for some reason it doesn't work - even after rebooting, though I can verify the extension is installed, "Generate Unit Test" doesn't show up in the context menu when I right-click within a method.

The next thing I tried was a workaround I found in one of the reviews - apparently the original feature still exists, just buried. The workaround is:

Tools->Options Environment->Keyboard Show commands containing 'unit' Attach a shortcut to "EditorContextMenus.CodeWindow.CreateUnitTests".

But that didn't work, either - as in, nothing seems to happen. There are two other commands that may be relevant - EditorContextMenus.CodeWindow.GenerateUnitTests and Project.AddUnitTest. Neither of those work either - the latter just does nothing, the former gives me the error "Controller must have testable element property set up".

So... I'm not really sure what else to try.

最满意答案

我有同样的问题,这里是错误发生的原因。

在代码生成器的文档中,arthor提出了一个超级重要的先决条件

在最终版本中,我们需要一个公开课程和至少一个公开课程,在生成单元测试功能亮起之前。

http://blogs.msdn.com/b/willy-peter_schaub/archive/2013/07/19/exploring-the-unit-test-generator-vs-extension-v1-rc.aspx

从文章中,我发现Code Generator有两个要求。

班级必须是公开的 班上至少有一种公开的方法

您可以尝试将Access修饰符设置为Public来解决问题

I have a same problem, and here is reason why the error occurred.

In the documentation of code generator, the arthor metions an super important pre-requisite.

In the final release we require a public class and at least one public method, before the Generate Unit Test feature lights up.

http://blogs.msdn.com/b/willy-peter_schaub/archive/2013/07/19/exploring-the-unit-test-generator-vs-extension-v1-rc.aspx

From the article, I have found that there is two requirements make the Code Generator works.

The class must be public At least one public method in the class

You can try to make the Access modifiers to Public to solve the problem

更多推荐

本文发布于:2023-08-05 05:21:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1427239.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控制器   属性   单元测试   元素   测试

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!