当前位置: 首页>>代码示例>>Java>>正文


Java CaseResult类代码示例

本文整理汇总了Java中hudson.tasks.junit.CaseResult的典型用法代码示例。如果您正苦于以下问题:Java CaseResult类的具体用法?Java CaseResult怎么用?Java CaseResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CaseResult类属于hudson.tasks.junit包,在下文中一共展示了CaseResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prepareTestResults

import hudson.tasks.junit.CaseResult; //导入依赖的package包/类
/**
 * Collects Surefire test results
 * @param suites
 * @param packageNames
 * @return
 */
private Map<String, Boolean> prepareTestResults(Collection<SuiteResult> suites,	Set<String> packageNames) {
	Map<String,Boolean> zephyrTestCaseMap = new HashMap<String, Boolean>();
	for (Iterator<SuiteResult> iterator = suites.iterator(); iterator
			.hasNext();) {
		SuiteResult suiteResult = iterator.next();
		List<CaseResult> cases = suiteResult.getCases();
		for (CaseResult caseResult : cases) {
			boolean isPassed = caseResult.isPassed();
			String name = caseResult.getFullName();
			if (!zephyrTestCaseMap.containsKey(name)) {
				zephyrTestCaseMap.put(name, isPassed);
				packageNames.add(caseResult.getPackageName());
			}
		}
	}
	return zephyrTestCaseMap;
}
 
开发者ID:zephyrdeveloper,项目名称:zee-jenkins,代码行数:24,代码来源:ZeeReporter.java

示例2: convertJUnit

import hudson.tasks.junit.CaseResult; //导入依赖的package包/类
/**
 * Convert JUnit's TestResult representation into a generic UnitResults
 * @param jUnitResults The result of the JUnit run
 * @return The converted results
 */
public UnitResults convertJUnit(TestResult jUnitResults) {
    UnitResults results = new UnitResults();
    if (jUnitResults == null) {
        return results;
    }
    for (SuiteResult sr : jUnitResults.getSuites()) {
        for (CaseResult cr : sr.getCases()) {
            UnitResult result = new UnitResult(
                    cr.getClassName(),
                    cr.getDisplayName(),
                    cr.getErrorStackTrace(),
                    cr.getDuration(),
                    cr.getFailCount(),
                    cr.getSkipCount(),
                    cr.getPassCount()
            );
            results.add(result);
        }
    }
    return results;
}
 
开发者ID:uber,项目名称:phabricator-jenkins-plugin,代码行数:27,代码来源:JUnitTestProvider.java

示例3: setupCaseResultList

import hudson.tasks.junit.CaseResult; //导入依赖的package包/类
static List<CaseResult> setupCaseResultList() {
  CaseResult caseOne = mock(CaseResult.class);
  CaseResult caseTwo = mock(CaseResult.class);
  CaseResult caseThree = mock(CaseResult.class);

  when(caseOne.getClassName()).thenReturn(TEST_CLASS_ONE);
  when(caseOne.getName()).thenReturn(TEST_METHOD_ONE);

  when(caseTwo.getClassName()).thenReturn(TEST_CLASS_ONE);
  when(caseTwo.getName()).thenReturn(TEST_METHOD_TWO);

  when(caseThree.getClassName()).thenReturn(TEST_CLASS_TWO);
  when(caseThree.getName()).thenReturn(TEST_METHOD_ONE);

  List<CaseResult> caseResultList = new ArrayList<CaseResult>();
  caseResultList.add(caseOne);
  caseResultList.add(caseTwo);
  caseResultList.add(caseThree);
  return caseResultList;
}
 
开发者ID:jenkinsci,项目名称:flaky-test-handler-plugin,代码行数:21,代码来源:DeflakeListenerTest.java

示例4: getTestAction

import hudson.tasks.junit.CaseResult; //导入依赖的package包/类
@Override
public List<TestAction> getTestAction(TestObject testObject) {

   if (build.getParent().getPublishersList().get(QuarantinableJUnitResultArchiver.class) == null) {
      // only display if QuarantinableJUnitResultArchiver chosen, to avoid
      // confusion
      System.out.println("not right publisher");
      return Collections.emptyList();
   }

   String id = testObject.getId();
   QuarantineTestAction result = quarantines.get(id);

   if (result != null) {
      return Collections.<TestAction> singletonList(result);
   }

   if (testObject instanceof CaseResult) {
      return Collections.<TestAction> singletonList(new QuarantineTestAction(this, id));
   }
   return Collections.emptyList();
}
 
开发者ID:samsta,项目名称:quarantine,代码行数:23,代码来源:QuarantineTestDataPublisher.java

示例5: getQuarantinedTests

import hudson.tasks.junit.CaseResult; //导入依赖的package包/类
public List<CaseResult> getQuarantinedTests() {
   ArrayList<CaseResult> list = new ArrayList<CaseResult>();
   for (TopLevelItem item : getOwner().getItems()) {
      if (item instanceof Job) {
         Job job = (Job) item;
         Run lb = job.getLastBuild();
         while (lb != null && (lb.hasntStartedYet() || lb.isBuilding()))
            lb = lb.getPreviousBuild();

         if (lb != null && lb.getAction(TestResultAction.class) != null) {
            for (SuiteResult suite : lb.getAction(TestResultAction.class).getResult().getSuites()) {
               for (CaseResult test : suite.getCases()) {
                  QuarantineTestAction action = test.getTestAction(QuarantineTestAction.class);
                  if (action != null && action.isQuarantined()) {
                     list.add(test);
                  }
               }
            }
         }
      }
   }
   return list;
}
 
开发者ID:samsta,项目名称:quarantine,代码行数:24,代码来源:QuarantinedTestsReport.java

示例6: testNoTestsHaveQuarantineActionForStandardPublisher

import hudson.tasks.junit.CaseResult; //导入依赖的package包/类
public void testNoTestsHaveQuarantineActionForStandardPublisher() throws Exception {
   project.getPublishersList().remove(QuarantinableJUnitResultArchiver.class);

   DescribableList<TestDataPublisher, Descriptor<TestDataPublisher>> publishers = new DescribableList<TestDataPublisher, Descriptor<TestDataPublisher>>(
         project);
   publishers.add(new QuarantineTestDataPublisher());
   project.getPublishersList().add(new JUnitResultArchiver("*.xml", false, publishers));

   TestResult tr = getResultsFromJUnitResult("junit-1-failure.xml");

   for (SuiteResult suite : tr.getSuites()) {
      for (CaseResult result : suite.getCases()) {
         assertNull(result.getTestAction(QuarantineTestAction.class));
      }
   }
}
 
开发者ID:samsta,项目名称:quarantine,代码行数:17,代码来源:QuarantineCoreTest.java

示例7: getTestAge

import hudson.tasks.junit.CaseResult; //导入依赖的package包/类
private int getTestAge(CaseResult result) {
    if (result.isPassed())
        return 0;
    else if (result.getRun() != null) {
        return result.getRun().getNumber() - result.getFailedSince() + 1;
    } else {
        return 0;
    }
}
 
开发者ID:wanyukang,项目名称:custom-notifier-plugin,代码行数:10,代码来源:FailedTestsContent.java

示例8: outputTest

import hudson.tasks.junit.CaseResult; //导入依赖的package包/类
private int outputTest(StringBuilder buffer, CaseResult failedTest,
                           boolean showStack, boolean showMessage, int lengthLeft) {
        StringBuilder local = new StringBuilder();

        local.append(failedTest.isPassed() ? "PASSED" : "FAILED").append(": ");

//        if(failedTest instanceof CaseResult) {
//            local.append(failedTest.getClassName());
//        } else {
//            local.append(failedTest.getFullName());
//        }
//        local.append('.').append(failedTest.getDisplayName()).append('\n');

        if (showMessage) {
            local.append("\nError Message:\n").append(failedTest.getErrorDetails()).append("\n");
        }

        if (showStack) {
            local.append("\nStack Trace:\n").append(failedTest.getErrorStackTrace()).append('\n');
        }

        if (showMessage || showStack) {
            local.append('\n');
        }

        if (local.length() > lengthLeft) {
            local.setLength(lengthLeft);
        }

        buffer.append(local.toString());
        return local.length();
    }
 
开发者ID:wanyukang,项目名称:custom-notifier-plugin,代码行数:33,代码来源:FailedTestsContent.java

示例9: getFailedTestCount

import hudson.tasks.junit.CaseResult; //导入依赖的package包/类
public int getFailedTestCount(SuiteResult suiteResult) {//work!

        int failedTestCount = 0;
        List<CaseResult> cases = suiteResult.getCases();
        for (CaseResult caseResult : cases) {
            if (!caseResult.isPassed() && !caseResult.isSkipped()) { // Any error, invalidates the suite result
                failedTestCount++;
            }
        }
        return failedTestCount;
    }
 
开发者ID:wanyukang,项目名称:custom-notifier-plugin,代码行数:12,代码来源:FailedTestsContent.java

示例10: contributeTestData

import hudson.tasks.junit.CaseResult; //导入依赖的package包/类
@Override
public TestResultAction.Data contributeTestData(Run<?, ?> run, @Nonnull FilePath workspace,
                                                Launcher launcher, TaskListener listener,
                                                TestResult testResult) throws IOException, InterruptedException {
    log(listener.getLogger(), "Publishing test results");
    Map<String, String> testSessionMap = workspace.act(new BrowserStackReportFileCallable(REPORT_FILE_PATTERN, run.getTimeInMillis()));
    AutomateActionData automateActionData = new AutomateActionData();
    Map<String, Long> testCaseIndices = new HashMap<String, Long>();

    int testCount = 0;
    int sessionCount = 0;

    for (SuiteResult suiteResult : testResult.getSuites()) {
        List<CaseResult> cases = suiteResult.getCases();
        testCount += cases.size();
        logDebug(listener.getLogger(), suiteResult.getName() + ": " + cases.size() + " test cases found.");

        for (CaseResult caseResult : cases) {
            String testCaseName = getTestCaseName(caseResult);

            Long testIndex = testCaseIndices.containsKey(testCaseName) ? testCaseIndices.get(testCaseName) : -1L;
            testCaseIndices.put(testCaseName, ++testIndex);
            logDebug(listener.getLogger(), testCaseName + " / " + testCaseName + " <=> " + testIndex);

            String testId = String.format("%s{%d}", testCaseName, testIndex);
            if (testSessionMap.containsKey(testId)) {
                AutomateTestAction automateTestAction = new AutomateTestAction(run, caseResult, testSessionMap.get(testId));
                automateActionData.registerTestAction(caseResult.getId(), automateTestAction);
                logDebug(listener.getLogger(), "registerTestAction: " + testId + " => " + automateTestAction);
                sessionCount++;
            }
        }
    }

    testCaseIndices.clear();
    log(listener.getLogger(), testCount + " tests recorded");
    log(listener.getLogger(), sessionCount + " sessions captured");
    log(listener.getLogger(), "Publishing test results: SUCCESS");
    return automateActionData;
}
 
开发者ID:jenkinsci,项目名称:browserstack-integration-plugin,代码行数:41,代码来源:AutomateTestDataPublisher.java

示例11: getTestAction

import hudson.tasks.junit.CaseResult; //导入依赖的package包/类
@Override
public List<? extends TestAction> getTestAction(TestObject testObject) {
    if (testObject instanceof CaseResult) {
        String caseResultId = testObject.getId();
        if (testActionMap.containsKey(caseResultId)) {
            return Collections.singletonList(testActionMap.get(caseResultId));
        }
    }

    return Collections.emptyList();
}
 
开发者ID:jenkinsci,项目名称:browserstack-integration-plugin,代码行数:12,代码来源:AutomateActionData.java

示例12: testThatReportsArePresent

import hudson.tasks.junit.CaseResult; //导入依赖的package包/类
@Test
public void testThatReportsArePresent() throws Exception {
    /* =================== Prepare ================= */
    new MockAutomateClient();

    addBuildStep();
    project.getBuildersList().add(new TouchBuilder());
    project.getBuildersList().add(new CopyResourceFileToWorkspaceTarget("browserstack-reports", "REPORT-com.browserstack.automate.application.tests.TestCaseWithFourUniqueSessions.xml"));
    project.getBuildersList().add(new CopyResourceFileToWorkspaceTarget("surefire-reports", "TEST-com.browserstack.automate.application.tests.TestCaseWithFourUniqueSessions.xml"));

    JUnitResultArchiver jUnitResultArchiver = new JUnitResultArchiver("**/surefire-reports/*.xml");
    jUnitResultArchiver.setTestDataPublishers(Collections.singletonList(new AutomateTestDataPublisher()));
    project.getPublishersList().add(jUnitResultArchiver);

    /* =================== Execute ================= */
    FreeStyleBuild build = project.scheduleBuild2(0).get();
    TestResultAction action = build.getAction(TestResultAction.class);

    /* =================== Verify ================= */
    List<TestResultAction.Data> testData = Deencapsulation.getField(action, "testData");
    // Assumption here is that there is only one suite result based on the XML files
    // copied into the workspace above.
    SuiteResult suiteResult = action.getResult().getSuites().iterator().next();

    jenkinsRule.assertBuildStatus(Result.SUCCESS, build);
    Assert.assertNotNull("Additional data on the test MUST be set.", testData);
    Assert.assertTrue("Additional Test data MUST have values.", testData.size() >= 1);
    TestResultAction.Data data = testData.get(0);
    Assert.assertTrue("Additional Test data MUST be an instance of AutomateActionData.", data instanceof AutomateActionData);

    for (CaseResult caseResult : suiteResult.getCases()) {
        AutomateTestAction automateTestAction = (AutomateTestAction) data.getTestAction(caseResult).get(0);
        Session automateSession = automateTestAction.getSession();
        Assert.assertNotNull("Automate Session should not be null.", automateSession);
        Assert.assertTrue("Session Id should not be null or empty.", StringUtils.isNotEmpty(automateSession.getId()));
    }
}
 
开发者ID:jenkinsci,项目名称:browserstack-integration-plugin,代码行数:38,代码来源:AutomateTestDataPublisherTest.java

示例13: getTextResult

import hudson.tasks.junit.CaseResult; //导入依赖的package包/类
@Override
public String getTextResult(Run<?, ?> run) {
    List<TestResultAction> actions = run.getActions(TestResultAction.class);
    StringBuilder builder = new StringBuilder();
    for (TestResultAction action : actions) {
        List<CaseResult> failedTests = action.getFailedTests();
        for (CaseResult result : failedTests) {
            builder.append(result.getTitle() + "\n");
            builder.append(result.getErrorDetails() + "\n");
        }
    }
    return builder.toString();
}
 
开发者ID:jenkinsci,项目名称:lucene-search-plugin,代码行数:14,代码来源:JunitFreeTextSearchExtension.java

示例14: getFailingTestClassMethodMap

import hudson.tasks.junit.CaseResult; //导入依赖的package包/类
/**
 * Organize failing test cases by their class names
 *
 * @param caseResultList all the failing test cases list
 * @return the map with class name and the set of test methods in each class
 */
static Map<String, Set<String>> getFailingTestClassMethodMap(List<CaseResult> caseResultList) {
  Map<String, Set<String>> classMethodMap = new HashMap<String, Set<String>>();
  if (caseResultList != null) {
    for (CaseResult caseResult : caseResultList) {
      if (!classMethodMap.containsKey(caseResult.getClassName())) {
        classMethodMap.put(caseResult.getClassName(), new HashSet<String>());
      }
      classMethodMap.get(caseResult.getClassName()).add(caseResult.getName());
    }
  }
  return classMethodMap;
}
 
开发者ID:jenkinsci,项目名称:flaky-test-handler-plugin,代码行数:19,代码来源:DeflakeListener.java

示例15: testGetFailingTestClassMethodMap

import hudson.tasks.junit.CaseResult; //导入依赖的package包/类
@Test
public void testGetFailingTestClassMethodMap() throws Exception {
  List<CaseResult> caseResultList = setupCaseResultList();
  Map<String, Set<String>> classMethodMap = DeflakeListener.getFailingTestClassMethodMap(
      caseResultList);
  assertEquals("Map size should be equal to number of classes", 2, classMethodMap.size());
  Set<String> expectedClassOneMethods = Sets.newHashSet(TEST_METHOD_ONE, TEST_METHOD_TWO);
  Set<String> expectedClassTwoMethods = Sets.newHashSet(TEST_METHOD_ONE);

  assertEquals("Incorrect test methods", expectedClassOneMethods,
      classMethodMap.get(TEST_CLASS_ONE));
  assertEquals("Incorrect test methods", expectedClassTwoMethods,
      classMethodMap.get(TEST_CLASS_TWO));
}
 
开发者ID:jenkinsci,项目名称:flaky-test-handler-plugin,代码行数:15,代码来源:DeflakeListenerTest.java


注:本文中的hudson.tasks.junit.CaseResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。