运行具体测试的快捷方式
我可以使用以下命令运行整个 Junit 测试:
Shift + Alt + X, T
但是我如何运行单次测试?使用鼠标单击具体方法并 Run As -> Junit test
有人知道这种情况的快捷方式吗?
谢谢
I can run the whole Junit test using:
Shift + Alt + X, T
But how I can run a single test? Using the mouse I click on concrete method and Run As -> Junit test
anyone know shortcut for this case ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
Shift + Alt + X,如果插入符位于方法名称上,则 T 运行一个测试方法。
Shift + Alt + X, T runs one test method if the caret is on the method name.
我发现“Shift-Alt-X”有时会给我带来麻烦,有时我认为是最后一个执行的命令并不总是如此,有时我最终会运行一些我无意的命令。此外,在进行 TDD 时,您会经常重新运行测试,有时想要从一个项目重新运行测试一段时间,然后您会转到下一个项目并想要开始运行其测试。或者您可能专注于特定领域并且只想运行一段时间的单个单元测试。在这种情况下,我发现我只想经常重新运行我最后的测试,并且我发现“Shift-Alt-X”有点麻烦。
所以我所做的是“Windows”> “首选项”然后单击“常规”> “钥匙”。按“命令”对表进行排序,然后向下滚动,直到找到“重新运行 JUnit 测试 - 首先失败”和“重新运行 JUnit 测试”。单击其中之一并将“绑定”字段设置为您要使用的任何键盘快捷键。就我个人而言,我将“重新运行 JUnit 测试”设置为 CTRL+F5,这样它类似于刷新浏览器(另外,这给了我快速、轻松的保存/重新运行组合,点击 < kbd>CTRL+S,然后 CTRL+F5)。
I find the "Shift-Alt-X" gives me trouble sometimes, sometimes what I think is the last executed command is not always and sometimes I end up running something I did not mean to. Also when doing TDD you rerun the tests so often and sometimes want to rerun the test from one project for a while, then you are on to the next project and want to start running its tests. Or you might be focusing on a specific area and only want to run a single unit test few a while. In this case I find I would like to simply rerun my last tests often and I find "Shift-Alt-X" to be a bit cumbersome.
So what I do is "Windows" > "Preferences" then click "General" > "Keys". Sort the table by "Command" and scroll down until you find "Rerun JUnit Test - Failures First" and "Rerun JUnit Test". Click on one of those and set the "Binding" field to whatever keyboard shortcut you want to use. Personally I set "Rerun JUnit Test" to CTRL+F5 so that its similar to refreshing a browser (plus this give me the quick and easy save/rerun combo of hitting CTRL+S, then CTRL+F5).
如果您按照您的描述运行单个测试方法,它将是“运行历史记录”中的最后一个条目。要再次运行测试,您只需单击工具栏中的运行按钮或按“Ctrl-F11”即可。
If you run the single test method as you described it will be the last entry in the "Run history". To run the test again you can simply click on the run button in the toolbar or press 'Ctrl-F11'.
F11 运行测试并激活窗口控制台。
Ctrl + F11 运行测试并激活窗口 JUnit。
F11 run test and activate window console.
Ctrl + F11 run test and activate window JUnit.
多年后,对我来说,有效的是 ALT+R+T+Enter ,它将运行最后一次运行的测试,无论它是特定的方法还是类。对我来说,CTL-F11 只运行最后一个 junit 类,即使最后一次运行是该 junit 类的特定方法。
Years later, for me, what works is ALT+R+T+Enter which would run the last ran test whether it's a specific method or class. CTL-F11 for me only runs the last junit class even if the last run was a specific method of that junit class.
快捷键:Ctrl+Alt+Shift+R - 仅运行一种单元测试方法。将插入符号设置为方法。
Shortcut: Ctrl+Alt+Shift+R - runs just one unit-test method. Set the caret to the method.
如果只想运行 test2,只需选择方法名称 test2,然后运行为--> JUnit。
它只会运行 test2 测试。
If you want to run test2 only, Just select method name test2, and run as-->JUnit.
It will run the test2 test only.