@Test
  public void testProbeInjectIntervalProbeToField() throws Exception {
    ProbeTest test = new ProbeTest();
    probesConfiguration.addConfig("latencyProbe", ProbesType.LATENCY.getName());
    testContainer = createTestContainer(test);

    assertNotNull(test.latencyProbe);
    assertTrue(testContainer.hasProbe("latencyProbe"));

    testContainer.invoke(TestPhase.RUN);
    Map<String, Result<?>> resultMap = testContainer.getProbeResults();
    assertNotNull(resultMap);
    assertTrue(resultMap.keySet().contains("latencyProbe"));
  }
  @Test
  public void testRunAnnotationInheritance() throws Exception {
    // @Setup method will be called from dummy class, not from child class
    // @Run method will be called from child class, not from dummy class
    ChildWithOwnRunMethodTest test = new ChildWithOwnRunMethodTest();
    testContainer = createTestContainer(test);
    testContainer.invoke(TestPhase.SETUP);
    testContainer.invoke(TestPhase.RUN);

    // ChildWithOwnRunMethodTest
    assertTrue(test.childRunCalled);
    // DummySetupTest
    assertTrue(test.setupCalled);
    // DummyTest
    assertFalse(test.runCalled);
  }
  @Test
  public void testPerformanceWithException() throws Exception {
    PerformanceExceptionTest test = new PerformanceExceptionTest();
    testContainer = createTestContainer(test);
    long count = testContainer.getOperationCount();

    assertEquals(-1, count);
  }
  @Test
  public void testLocalProbeInjected() throws Exception {
    ProbeTest test = new ProbeTest();
    testContainer = createTestContainer(test);
    testContainer.invoke(TestPhase.SETUP);

    assertNotNull(test.simpleProbe);
  }
  @Test
  public void testRun() throws Exception {
    DummyTest test = new DummyTest();
    testContainer = createTestContainer(test);
    testContainer.invoke(TestPhase.RUN);

    assertTrue(test.runCalled);
  }
  @Test
  public void testMessageReceiver() throws Exception {
    ReceiveTest test = new ReceiveTest();
    testContainer = createTestContainer(test);
    Message message = Mockito.mock(Message.class);
    testContainer.sendMessage(message);

    assertEquals(message, test.messagePassed);
  }
  @Test
  public void testGlobalTeardown() throws Exception {
    TeardownTest test = new TeardownTest();
    testContainer = createTestContainer(test);
    testContainer.invoke(TestPhase.GLOBAL_TEARDOWN);

    assertFalse(test.localTeardownCalled);
    assertTrue(test.globalTeardownCalled);
  }
  @Test
  public void testGlobalVerify() throws Exception {
    VerifyTest test = new VerifyTest();
    testContainer = createTestContainer(test);
    testContainer.invoke(TestPhase.GLOBAL_VERIFY);

    assertFalse(test.localVerifyCalled);
    assertTrue(test.globalVerifyCalled);
  }
  @Test
  public void testGlobalWarmup() throws Exception {
    WarmupTest test = new WarmupTest();
    testContainer = createTestContainer(test);
    testContainer.invoke(TestPhase.GLOBAL_WARMUP);

    assertFalse(test.localWarmupCalled);
    assertTrue(test.globalWarmupCalled);
  }
  @Test
  public void testProbeInjectExplicitlyNamedProbeToField() {
    ProbeTest test = new ProbeTest();
    probesConfiguration.addConfig("explicitProbeInjectedToField", ProbesType.THROUGHPUT.getName());
    testContainer = createTestContainer(test);

    assertNotNull(test.fooProbe);
    assertTrue(testContainer.hasProbe("explicitProbeInjectedToField"));
  }
  @Test
  public void testSetup() throws Exception {
    DummySetupTest test = new DummySetupTest();
    testContainer = createTestContainer(test);
    testContainer.invoke(TestPhase.SETUP);

    assertTrue(test.setupCalled);
    assertSame(testContext, test.context);
    assertFalse(test.runCalled);
  }
  @Test
  public void testRunWithIWorker() throws Exception {
    final RunWithIWorkerTest test = new RunWithIWorkerTest();
    testContainer = createTestContainer(test);
    Thread testStopper =
        new Thread() {
          @Override
          public void run() {
            while (!test.runWithWorkerCalled) {
              sleepMillis(50);
            }
            testContext.stop();
          }
        };

    testStopper.start();
    testContainer.invoke(TestPhase.RUN);
    testStopper.join();

    assertTrue(test.runWithWorkerCalled);
  }
 @Test
 public void testConstructor_getTestContext() {
   testContainer = createTestContainer(new DummyTest());
   assertEquals(testContext, testContainer.getTestContext());
 }