Search code examples
javadebuggingjunittestcase

Can I force Junit debugger to start debugging execution by a custom test case method using Eclipse IDE?


I have a Test Class containing 3 test methods like below example

public class SampleTest {
    @Test
    public void testAdd() {
        // logic of testing ADD
    }
    @Test
    public void testUpdate() {
        // logic of testing UPDATE
    }
    @Test
    public void testDelete() {
        // logic of testing Delete
    }
}

I want to debug ONLY the second method testUpdate()
WITHOUT starting execution by any of other test cases testAdd()/testDelete()

When I put breakpoints in all test methods
I found that
Order of Execution not granted, and in some cases testAdd()/testDelete() methods runs before testUpdate()
Those cases waste a time because, I need to debug ONLY method2 = testUpdate(),
So why I should wait method1 or method3 to be executed however they are run quickly

To summarize
Can I force Junit debugger to start execution by a custom test case method using Eclipse IDE?


Solution

  • Thanks a lot to @Dmytro comment.
    The solution will be

    1. In the Package Explorer or Outline view
    2. Unfold the Test Class which contain test methods.
    3. Right click on the required method you want to Debug
    4. Select Debug As => JUnit Test