Skip to content

First line lambda breakpoint cause breakpoints to not work #488

@gayanper

Description

@gayanper

Take the following example code

package com.example.demo;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import java.util.List;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
class Test {
	private List<Integer> mock = mock(List.class);

	@Test
	void testMain() {
		//System.out.println();
		when(mock.get(anyInt())).thenAnswer(invocation -> invocation.getArgument(0));

		assertEquals(mock.get(0), 0);
	}
}

If I try to put a breakpoint at second line of the method, the breakpoint will be skipped, it happens to any line in the method.
But if I uncomment the //System.out.println(); everything is back to normal.

This behavior is observed in both latest release or pre-release versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions