@Test
  public void testPagesForTestSystemAreSurroundedBySuiteSetupAndTeardown() throws Exception {
    WikiPage slimPage = addTestPage(suite, "AaSlimTest", simpleSlimDecisionTable);
    WikiPage setUp = crawler.addPage(root, PathParser.parse("SuiteSetUp"), "suite set up");
    WikiPage tearDown = crawler.addPage(root, PathParser.parse("SuiteTearDown"), "suite tear down");

    testPages = new LinkedList<WikiPage>();
    testPages.add(setUp);
    testPages.add(slimPage);
    testPages.add(testPage);
    testPages.add(tearDown);

    MultipleTestsRunner runner = new MultipleTestsRunner(testPages, context, suite, null);
    Map<TestSystem.Descriptor, LinkedList<TestPage>> map = runner.makeMapOfPagesByTestSystem();
    TestSystem.Descriptor fitDescriptor =
        TestSystem.getDescriptor(testPage.getData(), context.pageFactory, false);
    TestSystem.Descriptor slimDescriptor =
        TestSystem.getDescriptor(slimPage.getData(), context.pageFactory, false);

    List<TestPage> fitList = map.get(fitDescriptor);
    List<TestPage> slimList = map.get(slimDescriptor);

    assertEquals(3, fitList.size());
    assertEquals(3, slimList.size());

    assertEquals(setUp, fitList.get(0).getSourcePage());
    assertEquals(testPage, fitList.get(1).getSourcePage());
    assertEquals(tearDown, fitList.get(2).getSourcePage());

    assertEquals(setUp, slimList.get(0).getSourcePage());
    assertEquals(slimPage, slimList.get(1).getSourcePage());
    assertEquals(tearDown, slimList.get(2).getSourcePage());
  }
  @Test
  public void testBuildClassPath() throws Exception {
    MultipleTestsRunner runner = new MultipleTestsRunner(testPages, context, suite, null);

    String classpath = runner.buildClassPath();
    assertSubString("classes", classpath);
    assertSubString("dummy.jar", classpath);
  }
  @Test
  public void announceTotalTestsToRunShouldStartTotalTimeMeasurement() throws Exception {
    List<WikiPage> testPagesToRun = mock(List.class);
    WikiPage page = mock(WikiPage.class);
    FitNesseContext fitNesseContext = mock(FitNesseContext.class);
    ResultsListener resultsListener = mock(ResultsListener.class);
    MultipleTestsRunner runner =
        new MultipleTestsRunner(testPagesToRun, fitNesseContext, page, resultsListener);

    runner.announceTotalTestsToRun(new PagesByTestSystem());
    verify(resultsListener).announceNumberTestsToRun(0);
    assertThat(runner.totalTestTime, isAStartedTimeMeasurement());
  }
  @Test
  public void startingNewTestShouldStartTimeMeasurementAndNotifyListener() throws Exception {
    List<WikiPage> testPagesToRun = mock(List.class);
    TestPage page = new TestPage(mock(WikiPage.class));
    FitNesseContext fitNesseContext = mock(FitNesseContext.class);
    ResultsListener resultsListener = mock(ResultsListener.class);

    MultipleTestsRunner runner =
        new MultipleTestsRunner(
            testPagesToRun, fitNesseContext, page.getSourcePage(), resultsListener);

    runner.startingNewTest(page);
    verify(resultsListener).newTestStarted(same(page), same(runner.currentTestTime));
    assertThat(runner.currentTestTime, isAStartedTimeMeasurement());
  }
  @Test
  public void testGenerateSuiteMapWithMultipleTestSystems() throws Exception {
    WikiPage slimPage = addTestPage(suite, "SlimTest", simpleSlimDecisionTable);

    MultipleTestsRunner runner = new MultipleTestsRunner(testPages, context, suite, null);
    Map<TestSystem.Descriptor, LinkedList<TestPage>> map = runner.makeMapOfPagesByTestSystem();

    TestSystem.Descriptor fitDescriptor =
        TestSystem.getDescriptor(testPage.getData(), context.pageFactory, false);
    TestSystem.Descriptor slimDescriptor =
        TestSystem.getDescriptor(slimPage.getData(), context.pageFactory, false);
    List<TestPage> fitList = map.get(fitDescriptor);
    List<TestPage> slimList = map.get(slimDescriptor);

    assertEquals(1, fitList.size());
    assertEquals(1, slimList.size());
    assertEquals(testPage, fitList.get(0).getSourcePage());
    assertEquals(slimPage, slimList.get(0).getSourcePage());
  }
  @Test
  public void testCompleteShouldRemoveHeadOfQueueAndNotifyListener() throws Exception {
    List<WikiPage> testPagesToRun = mock(List.class);
    TestPage page = new TestPage(mock(WikiPage.class));
    FitNesseContext fitNesseContext = mock(FitNesseContext.class);
    ResultsListener resultsListener = mock(ResultsListener.class);

    MultipleTestsRunner runner =
        new MultipleTestsRunner(
            testPagesToRun, fitNesseContext, page.getSourcePage(), resultsListener);
    runner.addToProcessingQueue(page);

    TestSummary testSummary = mock(TestSummary.class);

    runner.startingNewTest(page);
    runner.testComplete(testSummary);
    verify(resultsListener)
        .testComplete(same(page), same(testSummary), same(runner.currentTestTime));
    assertThat(runner.currentTestTime, isAStoppedTimeMeasurement());
  }