KARR, DAVID
unread,May 17, 2013, 6:20:39 PM5/17/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to powe...@googlegroups.com
I need to capture an argument sent to a static method in a mocked object. I actually think I've got this working, but it seems so odd (even odder than normal Mockito code seems), I'd just like to make sure this is doing what I think it's doing.
In class FooTest, I have a @PrepareForTest that includes "Bar.class", and in my @Before method I have a "PowerMockito.mockStatic(Bar.class)" statement.
I've defined an ArgumentCaptor instance variable with the @Captor annotation.
In my test method, AFTER it calls the code under test, I have the following:
PowerMockito.verifyStatic();
Bar.staticMethod(captor.capture());
<Type> value = captor.getValue();
assertThat(value).isEqualTo(...);
Is this the correct sequence of events?