Bug 541277 - Running/Debug one test method
Summary: Running/Debug one test method
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.1   Edit
Hardware: All All
: P3 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-18 01:38 EST by Mario Kusek CLA
Modified: 2018-11-20 00:38 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mario Kusek CLA 2018-11-18 01:38:00 EST
This is proposal for feature related to writing JUnit tests.

When I am writing test in editor I would like to run/debug that test method that I am writing. Currently there is command that run all test methods in one class but I would like to run just one that I am currently having cursor at.

If there is command for that then I could bind it to some keys.
Comment 1 Karsten Thoms CLA 2018-11-18 17:09:53 EST
You can use CMD+ALT+X (Open Run menu) and then "T" for JUnit tests. This will execute all tests when cursor is somewhere in the unit test class. When the cursor is on a test method, it will only execute this.

Is this what you are searching for?
Comment 2 Mario Kusek CLA 2018-11-19 01:18:59 EST
No. This will run all tests in test methods in one class that I am editing. I would like to run only one test method that I am currently in with cursor.
Comment 3 Karsten Thoms CLA 2018-11-19 02:32:58 EST
As I said: Put the cursor on the method name, and then only this method is executed, not all in the class.
Comment 4 Karsten Thoms CLA 2018-11-19 02:35:17 EST
However, this might be improvable to run the test method only that the cursor is IN.

Also worth to mention is the codemining extension for JDT: https://github.com/angelozerr/jdt-codemining
This will eventually integrated into JDT. With that you can have actions to execute single tests above the test method.
Comment 5 Mario Kusek CLA 2018-11-19 03:03:14 EST
Regarding this:
> As I said: Put the cursor on the method name, and then only this method is 
> executed, not all in the class.

I didn't know for this feature that if you are on method name that it will run only this method.

But is it not very practical. It would be mot practical as you suggested:

> However, this might be improvable to run the test method only that the cursor is IN.


Regarding:
> Also worth to mention is the codemining extension for JDT:
> https://github.com/angelozerr/jdt-codemining
> This will eventually integrated into JDT. With that you can have actions 
> to execute single tests above the test method.

I am using it, but it is not exposed as Command and in key bindings I can not mapped it to keys.
Comment 6 Stephan Herrmann CLA 2018-11-19 18:30:11 EST
(In reply to Karsten Thoms from comment #4)
> However, this might be improvable to run the test method only that the
> cursor is IN.

I'm not sure that would be an improvement, as it would make running *all tests* of a class significantly more difficult (hunt for the whitespace between some methods ...).
Comment 7 Karsten Thoms CLA 2018-11-20 00:38:10 EST
How is the behavior in other IDEs regarding the per method/per class activation? We need more insights about what is actually better usable. Stephan's remark is absolutely valid.