Running a single JUnit test in Eclipse

后端 未结 13 568
面向向阳花
面向向阳花 2020-11-27 15:05

If I have a test suite with multiple tests, when I try to run a single unit test, either from the context menu of the code editor, or from the JUnit view, it seems to insist

13条回答
  •  -上瘾入骨i
    2020-11-27 15:50

    I'll add to the others by including a highly productive keyboard only way that allows you to debug a single unit test (method).

    Move your cursor to the method name by using either

    • Ctrl+Shift+Up or
    • Ctrl+Shift+Down or
    • Ctrl+o then type the name of the method

    Once your cursor is on the method name (or right before it):

    • Alt+Shift+D -> T (Debug)
    • Alt+Shift+X -> T (Run)

    After you run the test you can go back to where your cursor was by doing:

    Alt+Back

    You almost get REPL like behavior by:

    Ctrl+Shift+Up and Alt+Shift+X -> T and Alt+Back

    You can also quickly set a breakpoint:

    Ctrl+Shift+B

提交回复
热议问题