Skip to content

First line lambda breakpoint cause breakpoints to not work #488

Closed

Description

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.

Activity

  1. added a commit that references this issue on May 25, 2023
    135749e
  2. added a commit that references this issue on Jan 30, 2024
    d37cb10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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