Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Commit

Permalink
[JENKINS-39542] Ath test for test results
Browse files Browse the repository at this point in the history
  • Loading branch information
imeredith committed Dec 14, 2016
1 parent 7c10546 commit 0bc7cd4
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/js/page_objects/blueocean/bluePipelineActivity.js
Expand Up @@ -82,6 +82,16 @@ module.exports.commands = [{
this.waitForElementVisible('.activity-table tr#' + runName + ' svg.svgResultStatus');
this.waitForElementPresent('.activity-table tr#' + runName + ' svg circle.failure');
},

/**
* Wait for a specific run to appear in the activity table as unstable
* @param runName name of the job
*/
waitForRunUnstableVisible: function(runName) {
this.waitForElementVisible('.activity-table tr#' + runName);
this.waitForElementVisible('.activity-table tr#' + runName + ' svg.svgResultStatus');
this.waitForElementPresent('.activity-table tr#' + runName + ' svg circle.unstable');
},
/**
* Wait for a specific run to appear in the activity table as running
* @param runName name of the job
Expand Down
44 changes: 44 additions & 0 deletions src/test/js/multibranch/testResults.js
@@ -0,0 +1,44 @@
const tmp = require('tmp');
const async = require('async');

const repo = tmp.dirSync();
const pathToRepo = repo.name;
const jobName = 'testResults';
const path = require("path");
const sourceRep = './src/test/resources/multibranch/test_results';
const git = require("../../../main/js/api/git");

/**
* @module commitMessages
* @memberof multibranch
* @description Creates 2 commits and checks that the latest commit message is shown
*/
module.exports = {

// ** creating a git repo */
before: function (browser, done) {
// we creating a git repo in target based on the src repo (see above)
git.createRepo(sourceRep, pathToRepo).then(done);
},

// Create the multibranch job
'Create Job': function (browser) {
var multibranchCreate = browser.page.multibranchCreate().navigate();
multibranchCreate.createBranch(jobName, pathToRepo);
},

'Open acitivty page wait for first run to finish': function(browser) {
const blueActivityPage = browser.page.bluePipelineActivity().forJob(jobName);
// validate that we have 3 activities from the previous tests
blueActivityPage.assertActivitiesToBeEqual(1);

blueActivityPage.waitForRunUnstableVisible(`${jobName}-1`)
},

'Create new commits and check activity and branches page for correct commit messages': (client) => {
const blueRunDetailsPage = brower.page.bluePipelineRunDetail().forRun(jobName, 'jenkins', 'master', 1);

blueRunDetailsPage.clickTab('tests');
},

}
7 changes: 7 additions & 0 deletions src/test/resources/multibranch/test_results/Jenkinsfile
@@ -0,0 +1,7 @@
node {
stage 'test'
sh 'mvn test'

stage 'finish'
step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*.xml'])
}
25 changes: 25 additions & 0 deletions src/test/resources/multibranch/test_results/pom.xml
@@ -0,0 +1,25 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>io.blueocean</groupId>
<artifactId>test_results</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Blueocean test results project</name>
<url>http://jenkins.io</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,38 @@
package org.sonatype.mavenbook;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

import java.lang.InterruptedException;
/**
* Unit test for simple App.
*/
public class TestResults extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public TestResults( String testName )
{
super( testName );
}

/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( TestResults.class );
}

/**
* Rigourous Test :-)
*/
public void testCase() throws InterruptedException
{
throw new InterruptedException();
}
}

0 comments on commit 0bc7cd4

Please sign in to comment.