shortcut to run concrete test

梦想的初衷 提交于 2019-11-29 07:15:51

问题


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


回答1:


Shift + Alt + X, T runs one test method if the caret is on the method name.




回答2:


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).




回答3:


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'.




回答4:


  • F11 run test and activate window console.

  • Ctrl + F11 run test and activate window JUnit.




回答5:


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.




回答6:


Shortcut: Ctrl+Alt+Shift+R - runs just one unit-test method. Set the caret to the method.



来源:https://stackoverflow.com/questions/5114930/shortcut-to-run-concrete-test

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!