use of samples.suppressmethod.SuppressMethod in project powermock by powermock.
the class StubMethodTest method whenStubbingInstanceMethodToThrowExceptionTheMethodThrowsTheStubbedException.
@Test
public void whenStubbingInstanceMethodToThrowExceptionTheMethodThrowsTheStubbedException() throws Exception {
Exception expected = new Exception("message");
stub(method(SuppressMethod.class, "getObject")).toThrow(expected);
SuppressMethod tested = new SuppressMethod();
try {
tested.getObject();
fail();
} catch (Exception e) {
assertEquals("message", e.getMessage());
}
}
use of samples.suppressmethod.SuppressMethod in project powermock by powermock.
the class StubMethodTest method whenStubbingInstanceMethodByPassingTheMethodTheMethodReturnsTheStubbedValue.
@Test
public void whenStubbingInstanceMethodByPassingTheMethodTheMethodReturnsTheStubbedValue() throws Exception {
String expected = "Hello";
stub(method(SuppressMethod.class, "getObject")).toReturn(expected);
SuppressMethod tested = new SuppressMethod();
assertEquals(expected, tested.getObject());
assertEquals(expected, tested.getObject());
}
use of samples.suppressmethod.SuppressMethod in project powermock by powermock.
the class SuppressMethodTest method testGetBoolean.
@Test
public void testGetBoolean() throws Exception {
suppress(method(SuppressMethod.class, "getBoolean"));
SuppressMethod tested = new SuppressMethod();
assertFalse("A method returning a boolean should return false after suppressing method code.", tested.getBoolean());
}
use of samples.suppressmethod.SuppressMethod in project powermock by powermock.
the class SuppressMethodTest method testGetByte.
@Test
public void testGetByte() throws Exception {
suppress(method(SuppressMethod.class, "getByte"));
SuppressMethod tested = new SuppressMethod();
assertEquals("A method returning a byte should return 0 after suppressing method code.", 0, tested.getByte());
}
use of samples.suppressmethod.SuppressMethod in project powermock by powermock.
the class SuppressMethodTest method testGetInt.
@Test
public void testGetInt() throws Exception {
suppress(method(SuppressMethod.class, "getInt"));
SuppressMethod tested = new SuppressMethod();
assertEquals("A method returning an int should return 0 after suppressing method code.", 0, tested.getInt());
}
Aggregations