Package samples.junit4.annotationbased

Source Code of samples.junit4.annotationbased.AnnotationDemoWithSetupMethodTest

package samples.junit4.annotationbased;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.modules.junit4.PowerMockRunner;
import samples.Service;
import samples.annotationbased.AnnotationDemo;

import static org.easymock.EasyMock.expect;
import static org.junit.Assert.assertEquals;
import static org.powermock.api.easymock.PowerMock.replayAll;
import static org.powermock.api.easymock.PowerMock.verifyAll;

/**
* Verifies that PowerMock test listeners works correctly with setup methods.
*/
@RunWith(PowerMockRunner.class)
public class AnnotationDemoWithSetupMethodTest {

  @org.powermock.api.easymock.annotation.Mock
  private Service serviceMock;

  private AnnotationDemo tested;

  @Before
  public void setup() {
    tested = new AnnotationDemo(serviceMock);
  }

  @Test
  public void assertInjectionWorked() throws Exception {
    final String expected = "mock";
    expect(serviceMock.getServiceMessage()).andReturn(expected);

    replayAll();

    assertEquals(expected, tested.getServiceMessage());

    verifyAll();
  }
}
TOP

Related Classes of samples.junit4.annotationbased.AnnotationDemoWithSetupMethodTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.