Search in sources :

Example 36 with SuppressMethod

use of samples.suppressmethod.SuppressMethod in project powermock by powermock.

the class SuppressMethodTest method testSuppressMultipleMethods.

@Test
public void testSuppressMultipleMethods() throws Exception {
    suppress(methods(SuppressMethod.class, "getObject", "getShort"));
    SuppressMethod tested = new SuppressMethod();
    assertNull("A method returning Object should return null after suppressing method code.", tested.getObject());
    assertEquals("A method returning a short should return 0 after suppressing method code.", 0, tested.getShort());
}
Also used : SuppressMethod(samples.suppressmethod.SuppressMethod) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 37 with SuppressMethod

use of samples.suppressmethod.SuppressMethod in project powermock by powermock.

the class SuppressMethodTest method testGetLong.

@Test
public void testGetLong() throws Exception {
    suppress(method(SuppressMethod.class, "getLong"));
    SuppressMethod tested = new SuppressMethod();
    assertEquals("A method returning a long should return 0 after suppressing method code.", 0, tested.getLong());
}
Also used : SuppressMethod(samples.suppressmethod.SuppressMethod) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 38 with SuppressMethod

use of samples.suppressmethod.SuppressMethod in project powermock by powermock.

the class SuppressMethodTest method testGetShort.

@Test
public void testGetShort() throws Exception {
    suppress(method(SuppressMethod.class, "getShort"));
    SuppressMethod tested = new SuppressMethod();
    assertEquals("A method returning a short should return 0 after suppressing method code.", 0, tested.getShort());
}
Also used : SuppressMethod(samples.suppressmethod.SuppressMethod) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 39 with SuppressMethod

use of samples.suppressmethod.SuppressMethod in project powermock by powermock.

the class SuppressMethodTest method testGetObject.

@Test
public void testGetObject() throws Exception {
    suppress(method(SuppressMethod.class, "getObject"));
    SuppressMethod tested = new SuppressMethod();
    assertNull("A method returning Object should return null after suppressing method code.", tested.getObject());
}
Also used : SuppressMethod(samples.suppressmethod.SuppressMethod) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

Test (org.junit.Test)39 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)39 SuppressMethod (samples.suppressmethod.SuppressMethod)39 MethodNotFoundException (org.powermock.reflect.exceptions.MethodNotFoundException)2 TooManyMethodsFoundException (org.powermock.reflect.exceptions.TooManyMethodsFoundException)2 SuppressMethodExample (samples.suppressmethod.SuppressMethodExample)2 SuppressMethodParent (samples.suppressmethod.SuppressMethodParent)2 Callable (java.util.concurrent.Callable)1 Ignore (org.junit.Ignore)1 SuppressConstructorHierarchy (samples.suppressconstructor.SuppressConstructorHierarchy)1 SuppressField (samples.suppressfield.SuppressField)1