eclipse 运行具体测试的快捷方式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5114930/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
shortcut to run concrete test
提问by chris
I can run the whole Junit test using:
我可以使用以下命令运行整个 Junit 测试:
Shift+ Alt+ X, T
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
但是我如何才能运行一个测试?使用鼠标单击具体方法并Run As -> Junit test
anyone know shortcut for this case ?
有人知道这种情况的快捷方式吗?
Thanks
谢谢
回答by Thomas Jung
Shift+ Alt+ X, T runs one test method if the caret is on the method name.
Shift+ Alt+ X, 如果插入符号在方法名称上,T 将运行一种测试方法。
回答by rwblackburn
I find the "Shift-Alt-X" gives me trouble sometimes, sometimes what I thinkis 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.
我发现“ Shift- Alt- X”有时会给我带来麻烦,有时我认为上次执行的命令并不总是如此,有时我最终会运行一些我不想要的东西。此外,在进行 TDD 时,您经常重新运行测试,有时想从一个项目重新运行测试一段时间,然后您就开始下一个项目并希望开始运行其测试。或者您可能专注于特定领域并且只想运行一段时间的单个单元测试。在这种情况下,我发现我只想经常重新运行上次测试,但我发现“ Shift- Alt- X”有点麻烦。
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+F5so 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).
所以我要做的是“Windows”>“首选项”,然后单击“常规”>“键”。按“命令”对表格进行排序并向下滚动,直到找到“重新运行 JUnit 测试 - 首先失败”和“重新运行 JUnit 测试”。单击其中之一并将“绑定”字段设置为您要使用的任何键盘快捷键。就我个人而言,我将“重新运行 JUnit 测试”设置为CTRL+,F5这样它类似于刷新浏览器(另外,这使我可以快速轻松地保存/重新运行CTRL+S和CTRL+ 的组合F5)。
回答by FrVaBe
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'.
如果您按照您的描述运行单个测试方法,它将是“运行历史记录”中的最后一个条目。要再次运行测试,您只需单击工具栏中的运行按钮或按“Ctrl-F11”即可。
回答by Alessandro Cunha
F11run test and activate window console.
Ctrl+ F11run test and activate window JUnit.
F11运行测试并激活窗口控制台。
Ctrl+F11运行测试并激活窗口 JUnit。
回答by Mark
Shortcut: Ctrl+Alt+Shift+R- runs just one unit-test method. Set the caret to the method.
快捷键:Ctrl+ Alt+ Shift+ R-道仅有一个单元测试方法。将插入符号设置为方法。
回答by mtkilbay
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.
多年后,对我来说,有效的是 ALT+R+T+Enter 它将运行最后运行的测试,无论它是特定的方法还是类。CTL-F11 对我来说只运行最后一个 junit 类,即使最后一次运行是该 junit 类的特定方法。