Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invocations#withCapture(List) does not capture null values #567

Closed
seyguai opened this issue Dec 13, 2018 · 0 comments
Closed

Invocations#withCapture(List) does not capture null values #567

seyguai opened this issue Dec 13, 2018 · 0 comments
Assignees
Labels
bug

Comments

@seyguai
Copy link

@seyguai seyguai commented Dec 13, 2018

Please provide the following information:

  • Version of JMockit that was used: 1.35 & +

  • Description of the problem:
    I don't know if this was intended, but withCapture does not match null values when using a list as holder.

@RunWith(JMockit.class)
public class WithCaptureTest {
  
  public static class Foo {
    public void foo(String arg) {
    }
  }
  
  @Test
  public void test(@Mocked Foo foo) {
    foo.foo("Hello");
    foo.foo(null);
    foo.foo("World");
    
    new Verifications() {{
      List<String> params = new ArrayList<>();
      foo.foo(withCapture(params));

      Assert.assertEquals(Arrays.asList("Hello", null, "World"), params);
    }};
  }
}

Culprit: CaptureMatcher#matches ignores null values when expectedType is set (always)

@rliesenfeld rliesenfeld self-assigned this Dec 15, 2018
@rliesenfeld rliesenfeld added the bug label Dec 15, 2018
@jmockit jmockit locked and limited conversation to collaborators Apr 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
2 participants
You can’t perform that action at this time.