Package junit4.tutorial_0_basic

Source Code of junit4.tutorial_0_basic.Example3TestWrapperTest$Env

package junit4.tutorial_0_basic;

import com.google.common.testing.TearDown;
import com.google.common.testing.TearDownAccepter;
import com.google.guiceberry.junit4.GuiceBerryRule;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.guiceberry.GuiceBerryModule;
import com.google.guiceberry.TestId;
import com.google.guiceberry.TestWrapper;

import org.junit.Rule;
import org.junit.Test;

public class Example3TestWrapperTest {

  @Rule
  public final GuiceBerryRule guiceBerry = new GuiceBerryRule(Env.class);

  @Test
  public void testOne() throws Exception {
    System.out.println("Inside testOne");
  }

  @Test
  public void testTwo() throws Exception {
    System.out.println("Inside testTwo");
  }

  public static final class Env extends AbstractModule {
    @Override
    protected void configure() {
      install(new GuiceBerryModule());
    }

    @Provides
    TestWrapper getTestWrapper(final TestId testId,
        final TearDownAccepter tearDownAccepter) {
     
      return new TestWrapper() {
       
        public void toRunBeforeTest() {
          tearDownAccepter.addTearDown(new TearDown() {
           
            public void tearDown() throws Exception {
              System.out.println("Ending: " + testId);
            }
          });
          System.out.println("Beginning: " + testId);
        }
      };
    }
  }
}
TOP

Related Classes of junit4.tutorial_0_basic.Example3TestWrapperTest$Env

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.