use of samples.newmocking.MyClass in project powermock by powermock.
the class WhenNewCases method testSimpleMultipleNew_withAtLeastOnce.
@Test
public void testSimpleMultipleNew_withAtLeastOnce() throws Exception {
ExpectNewDemo tested = new ExpectNewDemo();
MyClass myClassMock1 = mock(MyClass.class);
whenNew(MyClass.class).withNoArguments().thenReturn(myClassMock1);
tested.simpleMultipleNew();
verifyNew(MyClass.class, atLeastOnce()).withNoArguments();
}
use of samples.newmocking.MyClass in project powermock by powermock.
the class WhenNewCases method testExpectNewButNoNewCallWasMade.
@Test
public void testExpectNewButNoNewCallWasMade() throws Exception {
ExpectNewDemo tested = new ExpectNewDemo();
MyClass myClassMock1 = mock(MyClass.class);
whenNew(MyClass.class).withNoArguments().thenReturn(myClassMock1);
tested.makeDate();
try {
verifyNew(MyClass.class).withNoArguments();
fail("Should throw AssertionError!");
} catch (AssertionError e) {
assertEquals("Wanted but not invoked samples.newmocking.MyClass();\nActually, there were zero interactions with this mock.", e.getMessage());
}
}
use of samples.newmocking.MyClass in project powermock by powermock.
the class WhenNewCases method testSimpleSingleNew_withAtLeastOnce.
@Test
public void testSimpleSingleNew_withAtLeastOnce() throws Exception {
ExpectNewDemo tested = new ExpectNewDemo();
MyClass myClassMock1 = mock(MyClass.class);
whenNew(MyClass.class).withNoArguments().thenReturn(myClassMock1);
tested.simpleSingleNew();
verifyNew(MyClass.class, atLeastOnce()).withNoArguments();
}
use of samples.newmocking.MyClass in project powermock by powermock.
the class ExpectNewDemo method multipleNew.
public String multipleNew() {
MyClass myClass1 = new MyClass();
MyClass myClass2 = new MyClass();
final String message1 = myClass1.getMessage();
final String message2 = myClass2.getMessage();
return message1 + message2;
}
use of samples.newmocking.MyClass in project powermock by powermock.
the class ExpectNewDemo method invokeVoidMethod.
public void invokeVoidMethod() {
MyClass myClass = new MyClass();
myClass.voidMethod();
}
Aggregations