Package hudson.tasks.test

Examples of hudson.tasks.test.AbstractTestResultAction


    }

    @Test
    public void testGetContent_whenAllTestsPassedShouldGiveMeaningfulMessage()
            throws Exception {
        AbstractTestResultAction testResults = mock( AbstractTestResultAction.class );
        when( testResults.getFailCount() ).thenReturn( 0 );

        when( build.getAction(AbstractTestResultAction.class) ).thenReturn( testResults );

        String content = failedTestContent.evaluate( build, listener, FailedTestsContent.MACRO_NAME );
View Full Code Here


        assertSame( childReport2.result, testResults.get( 1 ) );
    }

    private ChildReport mockChildReport()
    {
        final AbstractTestResultAction testResultAction1 = mock( AbstractTestResultAction.class );
        when( testResultAction1.getResult() ).thenReturn( new TestResult() );
        return new ChildReport( mockBuild, testResultAction1 );
    }
View Full Code Here

     * aggregates downstream results, ignore contributed failures. This is
     * because at the time this trigger runs, the current build's aggregated
     * results aren't available yet, but those of the previous build may be.
     */
    protected int getNumFailures(AbstractBuild<?, ?> build) {
        AbstractTestResultAction a = build.getAction(AbstractTestResultAction.class);
        if (a instanceof AggregatedTestResultAction) {
            int result = 0;
            AggregatedTestResultAction action = (AggregatedTestResultAction) a;
            for (ChildReport cr : action.getChildReports()) {
                if (cr == null || cr.child == null || cr.child.getParent() == null) {
                    continue;
                }
                if (cr.child.getParent().equals(build.getParent())) {
                    if (cr.result instanceof TestResult) {
                        TestResult tr = (TestResult) cr.result;
                        result += tr.getFailCount();
                    }
                }
            }

            if (result == 0 && action.getFailCount() > 0) {
                result = action.getFailCount();
            }
            return result;
        }
        return a.getFailCount();
    }
View Full Code Here

        assertFalse(summary.isWorse);
        assertEquals(Messages.Run_Summary_NotBuilt(), summary.message);
    }
   
    private void buildHasTestResult(AbstractBuild build, int failedTests) {
        AbstractTestResultAction testResult = mock(AbstractTestResultAction.class);
        when(testResult.getFailCount()).thenReturn(failedTests);
       
        when(build.getTestResultAction()).thenReturn(testResult);
    }
View Full Code Here

        for (MavenModule mavenModule : m.getModules()) {
            System.out.println("module " + mavenModule.getName() + "/" + mavenModule.getDisplayName());
            if ("org.foobar:org.foobar.test".equals( mavenModule.getName() )) testModule = mavenModule;
        }

        AbstractTestResultAction trpa = testModule.getLastBuild().getTestResultAction();

        int totalCount = trpa.getTotalCount();
        assertEquals(1, totalCount);
    }
View Full Code Here

        for (MavenModule mavenModule : m.getModules()) {
            System.out.println("module " + mavenModule.getName() + "/" + mavenModule.getDisplayName());
            if ("org.foobar:org.foobar.test".equals( mavenModule.getName() )) testModule = mavenModule;
        }

        AbstractTestResultAction trpa = testModule.getLastBuild().getTestResultAction();

        int totalCount = trpa.getTotalCount();
        assertEquals(1, totalCount);
    }
View Full Code Here

     * @param worseOverride override the 'worse' parameter to this value.
     *   May be null in which case 'worse' is calculated based on the number of failed tests.
     */
    private Summary determineDetailedUnstableSummary(Boolean worseOverride) {
        if(((Run)this) instanceof AbstractBuild) {
            AbstractTestResultAction trN = ((AbstractBuild)(Run)this).getTestResultAction();
            Run prev = getPreviousBuild();
            AbstractTestResultAction trP = prev==null ? null : ((AbstractBuild) prev).getTestResultAction();
            if(trP==null) {
                if(trN!=null && trN.getFailCount()>0)
                    return new Summary(worseOverride != null ? worseOverride : true,
                            Messages.Run_Summary_TestFailures(trN.getFailCount()));
            } else {
                if(trN.getFailCount()!= 0) {
                    if(trP.getFailCount()==0)
                        return new Summary(worseOverride != null ? worseOverride : true,
                                Messages.Run_Summary_TestsStartedToFail(trN.getFailCount()));
                    if(trP.getFailCount() < trN.getFailCount())
                        return new Summary(worseOverride != null ? worseOverride : true,
                                Messages.Run_Summary_MoreTestsFailing(trN.getFailCount()-trP.getFailCount(), trN.getFailCount()));
                    if(trP.getFailCount() > trN.getFailCount())
                        return new Summary(worseOverride != null ? worseOverride : false,
                                Messages.Run_Summary_LessTestsFailing(trP.getFailCount()-trN.getFailCount(), trN.getFailCount()));
                   
                    return new Summary(worseOverride != null ? worseOverride : false,
                            Messages.Run_Summary_TestsStillFailing(trN.getFailCount()));
                }
            }
View Full Code Here

  public void testUrlShouldBeUrlEncoded() {
      TestResult result = mock(TestResult.class);
      AbstractBuild build = mock(AbstractBuild.class);
      when(build.getUrl()).thenReturn("/a build");
     
      AbstractTestResultAction action = mock(AbstractTestResultAction.class);
      when(action.getUrlName()).thenReturn("/action");
     
      when(result.getOwner()).thenReturn(build);
      when(result.getTestResultAction()).thenReturn(action);
      when(result.getUrl()).thenReturn("/some id with spaces");
     
View Full Code Here

    return msg + getFailedTestsReport(build);
  }

  private CharSequence getFailedTestsReport(AbstractBuild<?, ?> build) {
   
    AbstractTestResultAction testResultAction = build.getAction(AbstractTestResultAction.class);
    if (testResultAction == null || testResultAction.getFailCount() == 0) {
      return "";
    }
   
    StringBuilder buf = new StringBuilder();
    List<CaseResult> failedTests = testResultAction.getFailedTests();
    Collections.sort(failedTests, new Comparator<CaseResult>() {
      @Override
      public int compare(CaseResult o1, CaseResult o2) {
        if (o1.getAge() < o2.getAge()) {
          return -1;
View Full Code Here

  /**
   * Returns the full URL to the test details page for a given test result;
   */
  public static String getTestUrl(hudson.tasks.test.TestResult result) {
    String buildUrl = getBuildURL(result.getOwner());
    @SuppressWarnings("rawtypes")
        AbstractTestResultAction action = result.getTestResultAction();
   
    TestObject parent = result.getParent();
    TestResult testResultRoot = null;
    while(parent != null) {
      if (parent instanceof TestResult) {
        testResultRoot = (TestResult) parent;
        break;
      }
      parent = parent.getParent();
    }
   
    String testUrl = action.getUrlName()
      + (testResultRoot != null ? testResultRoot.getUrl() : "")
      + result.getUrl();
   
    String[] pathComponents = testUrl.split("/");
    StringBuilder buf = new StringBuilder();
View Full Code Here

TOP

Related Classes of hudson.tasks.test.AbstractTestResultAction

Copyright © 2018 www.massapicom. 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.