Domanda

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

È stato utile?

Soluzione

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

enter image description here

Altri suggerimenti

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

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 run test and activate window console.

  • Ctrl + F11 run test and activate window 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.

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top