本文整理汇总了Java中hudson.tasks.junit.SuiteResult类的典型用法代码示例。如果您正苦于以下问题:Java SuiteResult类的具体用法?Java SuiteResult怎么用?Java SuiteResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SuiteResult类属于hudson.tasks.junit包,在下文中一共展示了SuiteResult类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: prepareTestResults
import hudson.tasks.junit.SuiteResult; //导入依赖的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.SuiteResult; //导入依赖的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: getQuarantinedTests
import hudson.tasks.junit.SuiteResult; //导入依赖的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
示例4: testNoTestsHaveQuarantineActionForStandardPublisher
import hudson.tasks.junit.SuiteResult; //导入依赖的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
示例5: getFailedTestCount
import hudson.tasks.junit.SuiteResult; //导入依赖的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
示例6: contributeTestData
import hudson.tasks.junit.SuiteResult; //导入依赖的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
示例7: testThatReportsArePresent
import hudson.tasks.junit.SuiteResult; //导入依赖的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
示例8: testAllTestsHaveQuarantineAction
import hudson.tasks.junit.SuiteResult; //导入依赖的package包/类
public void testAllTestsHaveQuarantineAction() throws Exception {
TestResult tr = getResultsFromJUnitResult("junit-1-failure.xml");
for (SuiteResult suite : tr.getSuites()) {
for (CaseResult result : suite.getCases()) {
assertNotNull(result.getTestAction(QuarantineTestAction.class));
}
}
}
开发者ID:samsta,项目名称:quarantine,代码行数:10,代码来源:QuarantineCoreTest.java
示例9: evaluate
import hudson.tasks.junit.SuiteResult; //导入依赖的package包/类
@Override
public String evaluate(Run<?, ?> run, FilePath filePath, TaskListener listener, String testResultFile)
throws MacroEvaluationException, IOException, InterruptedException {
StringBuilder buffer = new StringBuilder();
TestResult testResult = new TestResult();
File junitFile = new File(testResultFile);
testResult.parse(junitFile);
SuiteResult suite = testResult.getSuites().iterator().next();
int failCount = getFailedTestCount(suite);
if (null == testResult) {
return "No tests ran.";
}
if (failCount == 0) {
buffer.append("All tests passed");
} else {
buffer.append(failCount).append(" tests failed.\n");
boolean showOldFailures = !onlyRegressions;
// if(maxLength < Integer.MAX_VALUE) {
// maxLength *= 1024;
// }
if (maxTests > 0) {
int printedTests = 0;
int printedLength = 0;
List<CaseResult> cases = suite.getCases();
for (CaseResult caseResult : cases) {
if (!caseResult.isPassed() && !caseResult.isSkipped() && caseResult.getErrorDetails() != null) { // Any error, invalidates the suite result
if (showOldFailures || getTestAge(caseResult) == 1) {
if (printedTests < maxTests && printedLength <= maxLength) {
printedLength += outputTest(buffer, caseResult, showStack, showMessage, maxLength - printedLength);
printedTests++;
}
}
}
}
if (failCount > printedTests) {
buffer.append("... and ").append(failCount - printedTests).append(" other failed tests.\n\n");
}
if (printedLength >= maxLength) {
buffer.append("\n\n... output truncated.\n\n");
}
}
}
return buffer.toString();
}
开发者ID:wanyukang,项目名称:custom-notifier-plugin,代码行数:52,代码来源:FailedTestsContent.java
示例10: prepareZephyrTests
import hudson.tasks.junit.SuiteResult; //导入依赖的package包/类
/**
* Collects the surefire results and prepares Zephyr Tests
* @param build
* @param zephyrConfig
* @return
*/
private boolean prepareZephyrTests(final AbstractBuild build,
ZephyrConfigModel zephyrConfig) {
boolean status = true;
TestResultAction testResultAction = build.getAction(TestResultAction.class);
Collection<SuiteResult> suites = null;
try {
suites = testResultAction.getResult().getSuites();
} catch (Exception e) {
logger.println(e.getMessage());
return false;
}
if (suites == null || suites.size() == 0) {
return false;
}
Set<String> packageNames = new HashSet<String>();
Map<String, Boolean> zephyrTestCaseMap = prepareTestResults(suites, packageNames);
logger.print("Total Test Cases : " + zephyrTestCaseMap.size());
List<TestCaseResultModel> testcases = new ArrayList<TestCaseResultModel>();
Set<String> keySet = zephyrTestCaseMap.keySet();
for (Iterator<String> iterator = keySet.iterator(); iterator.hasNext();) {
String testCaseName = iterator.next();
Boolean isPassed = zephyrTestCaseMap.get(testCaseName);
RemoteTestcase testcase = new RemoteTestcase();
testcase.setName(testCaseName);
testcase.setComments(TEST_CASE_COMMENT);
testcase.setAutomated(AUTOMATED);
testcase.setExternalId(EXTERNAL_ID);
testcase.setPriority(TEST_CASE_PRIORITY);
testcase.setTag(TEST_CASE_TAG);
TestCaseResultModel caseWithStatus = new TestCaseResultModel();
caseWithStatus.setPassed(isPassed);
caseWithStatus.setRemoteTestcase(testcase);
testcases.add(caseWithStatus);
}
zephyrConfig.setTestcases(testcases);
zephyrConfig.setPackageNames(packageNames);
zephyrConfig.setCreatePackage(createPackage);
return status;
}
开发者ID:zephyrdeveloper,项目名称:zee-jenkins,代码行数:57,代码来源:ZeeReporter.java
示例11: getTestData
import hudson.tasks.junit.SuiteResult; //导入依赖的package包/类
@Override
public Data getTestData(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener, TestResult testResult) {
Data data = new Data(build);
MailNotifier notifier = new MailNotifier(listener);
for (SuiteResult suite : testResult.getSuites()) {
for (CaseResult result : suite.getCases()) {
QuarantineTestAction previousAction = null;
CaseResult previous = result.getPreviousResult();
AbstractBuild<?, ?> previousBuild = build.getPreviousCompletedBuild();
if (previous != null) {
previousAction = previous.getTestAction(QuarantineTestAction.class);
}
// no immediate predecessor (e.g. because job failed or did not
// run), try and go back in build history
while (previous == null && previousBuild != null) {
if (previousBuild.getAction(AbstractTestResultAction.class) != null) {
hudson.tasks.test.TestResult tr = null;
try {
tr = previousBuild.getAction(AbstractTestResultAction.class).findCorrespondingResult(
result.getId());
}
catch (Exception e){
listener.getLogger().println("could not find result for id " + result.getId() + " in build " + previousBuild + ": " + e.getMessage());
}
if (tr != null) {
listener.getLogger().println("found " + tr.getDisplayName() + " in build " + previousBuild);
previousAction = tr.getTestAction(QuarantineTestAction.class);
break;
}
}
else
{
listener.getLogger().println("build " + previousBuild + " does not have test results");
}
previousBuild = previousBuild.getPreviousCompletedBuild();
}
if (previousAction != null && previousAction.isQuarantined()) {
QuarantineTestAction action = new QuarantineTestAction(data, result.getId());
action.quarantine(previousAction);
data.addQuarantine(result.getId(), action);
// send email if failed
if (!result.isPassed()) {
notifier.addResult(result, action);
}
}
}
}
notifier.sendEmails();
return data;
}
开发者ID:samsta,项目名称:quarantine,代码行数:57,代码来源:QuarantineTestDataPublisher.java
注:本文中的hudson.tasks.junit.SuiteResult类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论