Java 类hudson.tasks.test.AggregatedTestResultAction 实例源码

项目:delivery-pipeline-plugin    文件:TestResultTest.java   
@Test
public void testGetTestResult() {
    AbstractBuild<?, ?> build =  mock(AbstractBuild.class);
    AggregatedTestResultAction tests = mock(AggregatedTestResultAction.class);
    when(build.getAction(AbstractTestResultAction.class)).thenReturn(tests);
    when(tests.getDisplayName()).thenReturn("Test Result");
    when(tests.getFailCount()).thenReturn(1);
    when(tests.getSkipCount()).thenReturn(0);
    when(tests.getTotalCount()).thenReturn(11);

    List<TestResult> result = TestResult.getResults(build);
    assertNotNull(result);
    assertEquals(1, result.get(0).getFailed());
    assertEquals(0, result.get(0).getSkipped());
    assertEquals(11, result.get(0).getTotal());
    assertNotNull(result.get(0).getUrl());
    assertNotNull(result.get(0).getName());
}
项目:jenkins-github-pull-request-comments    文件:BuildFlowBuildManager.java   
/**
 * Return the tests results of a build of default type. This will be overriden by specific build types.
 *
 * @return the tests result of a build of default type
 */
@SuppressWarnings("unchecked")
@Override
public String getTestResults() {
    Iterator<JobInvocation> iterator = (Iterator<JobInvocation>) downstreamProjects();

    StringBuilder sb = new StringBuilder();

    while (iterator.hasNext()) {
        JobInvocation jobInvocation = iterator.next();

        try {
            AbstractBuild<?, ?> build = (AbstractBuild<?, ?>) jobInvocation.getBuild();

            AggregatedTestResultAction testResultAction = build.getAction(AggregatedTestResultAction.class);

            if (testResultAction != null) {
                sb.append("\n");
                sb.append(jobInvocation.getBuildUrl());
                sb.append("\n");
                sb.append(getAggregatedTestResults(build));
            }
        } catch (Exception e) {
            logger.log(Level.SEVERE, "Job execution has failed", e);
        }
    }

    return sb.toString();
}