use of samples.suppressmethod.SuppressMethod in project powermock by powermock.
the class SpyTest method testSuppressMethodWhenObjectIsSpy.
@Test
public void testSuppressMethodWhenObjectIsSpy() throws Exception {
suppress(method(SuppressMethod.class, "myMethod"));
SuppressMethod tested = spy(new SuppressMethod());
assertEquals(0, tested.myMethod());
}
use of samples.suppressmethod.SuppressMethod in project powermock by powermock.
the class SpyTest method testSuppressMethodInParentOnlyWhenObjectIsSpy.
@Test
public void testSuppressMethodInParentOnlyWhenObjectIsSpy() throws Exception {
suppress(method(SuppressMethodParent.class, "myMethod"));
SuppressMethod tested = spy(new SuppressMethod());
assertEquals(20, tested.myMethod());
}
use of samples.suppressmethod.SuppressMethod in project powermock by powermock.
the class MemberModificationExampleTest method suppressAllMethodsExample.
@Test
public void suppressAllMethodsExample() throws Exception {
suppress(methodsDeclaredIn(SuppressMethod.class));
final SuppressMethod tested = new SuppressMethod();
assertNull(tested.getObject());
assertNull(SuppressMethod.getObjectStatic());
assertEquals(0, tested.getByte());
}
use of samples.suppressmethod.SuppressMethod in project powermock by powermock.
the class StubMethodTest method whenStubbingInstanceMethodWithPrimiteValueTheMethodReturnsTheStubbedValue.
@Test
public void whenStubbingInstanceMethodWithPrimiteValueTheMethodReturnsTheStubbedValue() throws Exception {
float expectedValue = 4;
stub(method(SuppressMethod.class, "getFloat")).toReturn(expectedValue);
SuppressMethod tested = new SuppressMethod();
assertEquals(expectedValue, tested.getFloat(), 0.0f);
assertEquals(expectedValue, tested.getFloat(), 0.0f);
}
use of samples.suppressmethod.SuppressMethod in project powermock by powermock.
the class StubMethodTest method whenStubbingInstanceMethodTheMethodReturnsTheStubbedValue.
@Test
public void whenStubbingInstanceMethodTheMethodReturnsTheStubbedValue() throws Exception {
String expectedValue = "Hello";
stub(method(SuppressMethod.class, "getObject")).toReturn(expectedValue);
SuppressMethod tested = new SuppressMethod();
assertEquals(expectedValue, tested.getObject());
assertEquals(expectedValue, tested.getObject());
}
Aggregations