Пример #1
0
  protected void setUp() throws Exception {
    super.setUp();

    RobotParser.RobotParserCallable remoteOperation =
        new RobotParser.RobotParserCallable("output.xml", null, null);
    RobotResult result =
        remoteOperation.invoke(
            new File(new RobotGraphHelperTest().getClass().getResource("output.xml").toURI())
                .getParentFile(),
            null);
    result.tally(null);

    // Mocked builds to play as owners of test results
    FreeStyleBuild mockBuild1 = mock(FreeStyleBuild.class);
    FreeStyleBuild mockBuild2 = mock(FreeStyleBuild.class);
    when(mockBuild2.compareTo(mockBuild1)).thenReturn(1);
    when(mockBuild1.compareTo(mockBuild2)).thenReturn(-1);

    // This is to pass hudson.util.Graph constructor
    GregorianCalendar c = new GregorianCalendar();
    c.setTimeInMillis(0L);
    when(mockBuild1.getTimestamp()).thenReturn(c);
    when(mockBuild2.getTimestamp()).thenReturn(c);

    // set up some results chains
    mockResult1 = spy(result);
    doReturn(null).when(mockResult1).getPreviousResult();
    doReturn(mockBuild1).when(mockResult1).getOwner();

    mockResult2 = spy(result);
    doReturn(mockResult1).when(mockResult2).getPreviousResult();
    doReturn(mockBuild2).when(mockResult2).getOwner();
  }
  @LocalData
  public void testFailedSince() {
    Hudson hudson = Hudson.getInstance();
    List<Project> projects = hudson.getProjects();
    Run lastRun = null;
    for (Project project : projects) {
      if (project.getName().equalsIgnoreCase("failingtests")) {
        lastRun = project.getLastCompletedBuild();
      }
    }
    if (lastRun == null) fail("No build including Robot results was found");

    RobotBuildAction action = lastRun.getAction(RobotBuildAction.class);
    RobotResult result = action.getResult();
    RobotCaseResult firstFailed = result.getAllFailedCases().get(0);
    assertEquals(2, firstFailed.getFailedSince());
  }