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

Improve argument captors #79

Closed
nhaarman opened this issue Oct 3, 2016 · 0 comments
Closed

Improve argument captors #79

nhaarman opened this issue Oct 3, 2016 · 0 comments
Assignees
Milestone

Comments

@nhaarman
Copy link
Collaborator

nhaarman commented Oct 3, 2016

At the moment the behavior of using argument captors differs between the Kotlin and Java versions.
For example, the below Kotlin test fails, while the corresponding Java test passes:

@Test
fun testKotlin() {
    /* Given */
    val date: Date = mock()

    /* When */
    date.time = 5L
    date.time = 7L

    /* Then */
    verify(date, times(2)).time = capture {
        expect(it).toBe(7L)
    }
}
@Test
public void testJava() {
    /* Given */
    Date date = mock(Date.class);

    /* When */
    date.setTime(5L);
    date.setTime(7L);

    /* Then */
    ArgumentCaptor<Long> captor = ArgumentCaptor.forClass(Long.class);
    verify(date, times(2)).setTime(captor.capture());
    assert captor.getValue() == 7L;
}

The reason is that the Java version matches the latest captured value, while the current Kotlin version matches the first.

@nhaarman nhaarman modified the milestones: 0.7.0, 0.8.0 Oct 3, 2016
@nhaarman nhaarman self-assigned this Oct 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant