IntelliJ IDEA-导航到测试主题 [英] IntelliJ IDEA - Navigate to test subject

查看:195
本文介绍了IntelliJ IDEA-导航到测试主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在IntelliJ IDEA中工作时,我试图应用TDD原理,但是遇到问题,我不知道是否有我不知道会帮助我的功能或插件.

I'm trying to apply TDD principles when working in the IntelliJ IDEA but I'm encountering a problem and I don't know if there is a feature or a plugin I don't know about to help me.

我刚刚发现,您可以使用CTRL + SHIFT + T轻松导航到与编辑器中当前类相对应的测试类.如果测试类不存在,它将要求您创建它.

I've just discovered that you can easily Navigate to the test class corresponding to current class in the editor with CTRL + SHIFT + T. If the Test Class does not exist, it will ask you to create it.

在相反的情况下,当我创建一个没有相应测试主题的测试类并且按下上一个快捷方式时,它只会告诉我No test subjects found.

In a reverse situation, when I create a Test Class with no corresponding Test Subject and that I press the previous shortcut, it just tells me No test subjects found.

有没有一种方法可以在不存在的情况下快速创建测试主题类?

Is there a way to quickly create the test subject class when it does not exists?

推荐答案

如果您通过名称引用测试对象(例如,尝试创建一个类):

If you refer to the test subject by name (for example, try to create a class):

Hello hello = new Hello();

...然后,您可以使用从用法中创建类"快速修复程序来为您创建类.只需将名称放在"Hello"标识符上(将无法解析),然后按Alt-Enter.

...then you can use the "Create Class from Usage" quickfix to create the class for you. Simply put the name on the "Hello" identifier (which will be unresolved) and press Alt-Enter.

这篇关于IntelliJ IDEA-导航到测试主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆