-
Notifications
You must be signed in to change notification settings - Fork 238
Chained mocking not working in BeforeMethod #444
Copy link
Copy link
Closed
Labels
Description
1.33 fail
1.32 green
import java.util.List;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import mockit.Expectations;
import mockit.Mocked;
import static org.testng.Assert.assertNotNull;
public class JmockitTest {
@Mocked
private ContextData contextData;
@BeforeMethod
public void setUp() throws Exception {
new Expectations() {{
contextData.getUser().getAccounts();
result = ImmutableList.of(new Account());
}};
}
@Test
public void test() throws Exception {
assertNotNull(contextData.getUser().getAccounts());
}
interface ContextData {
User getUser();
}
static class User {
private List<Account> accounts;
public List<Account> getAccounts() {
return accounts;
}
public void setAccounts(final List<Account> accounts) {
this.accounts = accounts;
}
}
static class Account {
}
}
Reactions are currently unavailable