Search in sources :

Example 1 with SuppressConstructorHierarchy

use of samples.suppressconstructor.SuppressConstructorHierarchy in project powermock by powermock.

the class SuppressConstructorHierarchyDemoTest method testGetNumber.

/**
	 * This simple test demonstrate that it's possible to continue execution
	 * with the default {@code PrepareForTest} settings (i.e. using a
	 * byte-code manipulated version of the SuppressConstructorHierarchyDemo
	 * class).
	 */
public void testGetNumber() throws Exception {
    suppress(constructor(SuppressConstructorHierarchy.class));
    SuppressConstructorHierarchy tested = new SuppressConstructorHierarchy("message");
    assertEquals(42, tested.getNumber());
}
Also used : SuppressConstructorHierarchy(samples.suppressconstructor.SuppressConstructorHierarchy)

Example 2 with SuppressConstructorHierarchy

use of samples.suppressconstructor.SuppressConstructorHierarchy in project powermock by powermock.

the class SuppressConstructorHierarchyDemoTest method testSuppressConstructor.

public void testSuppressConstructor() throws Exception {
    suppress(constructor(SuppressConstructorHierarchy.class));
    SuppressConstructorHierarchy tested = new SuppressConstructorHierarchy("message");
    final String message = tested.getMessage();
    assertNull("Message should have been null since we're skipping the execution of the constructor code. Message was \"" + message + "\".", message);
}
Also used : SuppressConstructorHierarchy(samples.suppressconstructor.SuppressConstructorHierarchy)

Example 3 with SuppressConstructorHierarchy

use of samples.suppressconstructor.SuppressConstructorHierarchy in project powermock by powermock.

the class SuppressConstructorHierarchyDemoTest method testSuppressConstructorHierarchyAgain.

/**
 * This simple test demonstrate that it's possible to continue execution
 * with the default {@code PrepareForTest} settings (i.e. using a
 * byte-code manipulated version of the SuppressConstructorHierarchyDemo
 * class).
 */
@Test
public void testSuppressConstructorHierarchyAgain() throws Exception {
    suppress(constructor(SuppressConstructorHierarchy.class));
    SuppressConstructorHierarchy tested = new SuppressConstructorHierarchy("message");
    assertEquals(42, tested.getNumber());
}
Also used : SuppressConstructorHierarchy(samples.suppressconstructor.SuppressConstructorHierarchy) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 4 with SuppressConstructorHierarchy

use of samples.suppressconstructor.SuppressConstructorHierarchy in project powermock by powermock.

the class MemberModificationExampleTest method suppressConstructorExample.

@Test
public void suppressConstructorExample() throws Exception {
    suppress(constructor(SuppressConstructorHierarchy.class));
    SuppressConstructorHierarchy tested = new SuppressConstructorHierarchy("message");
    assertEquals(42, tested.getNumber());
    assertNull(tested.getMessage());
}
Also used : SuppressConstructorHierarchy(samples.suppressconstructor.SuppressConstructorHierarchy) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 5 with SuppressConstructorHierarchy

use of samples.suppressconstructor.SuppressConstructorHierarchy in project powermock by powermock.

the class MemberModificationExampleTest method suppressConstructorExample.

@Test
public void suppressConstructorExample() throws Exception {
    suppress(constructor(SuppressConstructorHierarchy.class));
    SuppressConstructorHierarchy tested = new SuppressConstructorHierarchy("message");
    assertEquals(42, tested.getNumber());
    assertNull(tested.getMessage());
}
Also used : SuppressConstructorHierarchy(samples.suppressconstructor.SuppressConstructorHierarchy) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

SuppressConstructorHierarchy (samples.suppressconstructor.SuppressConstructorHierarchy)10 Test (org.junit.Test)8 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)8 SuppressField (samples.suppressfield.SuppressField)1 SuppressMethod (samples.suppressmethod.SuppressMethod)1