Skip to content
Permalink
Browse files
[JENKINS-28588] Add unit test to make sure plugin works on a slave.
Add a unit test that runs the plugin on a slave to ensure no serialization
issues occur.
  • Loading branch information
jtnord committed May 27, 2015
1 parent 7478db5 commit 35fab782f1746218527d0fa5d55e8d39e62e0041
Showing 3 changed files with 194 additions and 1 deletion.
16 pom.xml
@@ -4,6 +4,7 @@
~
~ Copyright (c) 2014 James Nord
~ 2013, Cisco Systems, Inc., a California corporation
~ 2015 CloudBees, Inc.
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
@@ -35,7 +36,7 @@

<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>cucumber-testresult-plugin</artifactId>
<version>0.9-SNAPSHOT</version>
<version>0.8.2-SNAPSHOT</version>
<packaging>hpi</packaging>

<name>Cucumber json test reporting.</name>
@@ -122,6 +123,19 @@
<version>1.106</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18.1</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
@@ -0,0 +1,80 @@
/*
* The MIT License
*
* Copyright (c) 2015, CloudBees, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.jenkinsci.plugins.cucumber.jsontestsupport;

import java.io.File;
import java.net.URL;

import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
import hudson.model.Node;
import hudson.slaves.DumbSlave;

import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.SingleFileSCM;

import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;

public class CucumberJSONSupportPluginIT {

@Rule
public JenkinsRule jenkinsRule = new JenkinsRule();

@Test
@Issue("JENKINS-28588")
public void testSerializationOnSlave() throws Exception {
DumbSlave slave = jenkinsRule.createOnlineSlave();

SingleFileSCM scm = new SingleFileSCM("test.json",
getResource("passWithEmbeddedItem.json")
.toURI().toURL());

FreeStyleProject project = jenkinsRule.createFreeStyleProject("cucumber-plugin-IT");
project.setAssignedNode(slave);
project.setScm(scm);

CucumberTestResultArchiver resultArchiver = new CucumberTestResultArchiver("test.json");

project.getPublishersList().add(resultArchiver);

project.save();

FreeStyleBuild build = jenkinsRule.buildAndAssertSuccess(project);
jenkinsRule.assertLogContains("test.json", build);
// check we built on the slave not the master...

assertThat("Needs to build on the salve to check serialization", build.getBuiltOn(), is((Node) slave));
}

private static URL getResource(String resource) throws Exception {
URL url = CucumberJSONSupportPluginIT.class.getResource(CucumberJSONSupportPluginIT.class.getSimpleName() + "/" + resource);
Assert.assertNotNull("Resource " + resource + " could not be found", url);
return url;
}
}
@@ -0,0 +1,99 @@
[
{
"line": 1,
"elements": [
{
"line": 4,
"name": "I can connect to the database instance",
"description": "",
"id": "connectivity;i-can-connect-to-the-database-instance",
"after": [
{
"result": {
"duration": 9738454,
"status": "passed"
},
"match": {
"location": "JDBCStepDefs.embedScreenshot(Scenario)"
}
}
],
"type": "scenario",
"keyword": "Scenario",
"steps": [
{
"result": {
"duration": 1355975209,
"status": "passed"
},
"line": 5,
"name": "I have a server",
"match": {
"location": "JDBCStepDefs.i_have_a_server()"
},
"keyword": "Given "
},
{
"result": {
"duration": 71051,
"status": "passed"
},
"line": 6,
"name": "I have a username",
"match": {
"location": "JDBCStepDefs.i_have_a_username()"
},
"keyword": "And "
},
{
"result": {
"duration": 30789,
"status": "passed"
},
"line": 7,
"name": "I have a password",
"match": {
"location": "JDBCStepDefs.i_have_a_password()"
},
"keyword": "And "
},
{
"result": {
"duration": 87074513,
"status": "passed"
},
"line": 8,
"name": "I have registered the Oracle JDBC driver",
"match": {
"location": "JDBCStepDefs.i_register_the_Oracle_JDBC_driver()"
},
"keyword": "When "
},
{
"result": {
"duration": 28625433269,
"status": "passed"
},
"embeddings": [
{
"data": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAIAAAAiOjnJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAr7SURBVHhe7Z3Pi1ZVGMf9Q4oWFYFBoCA0ETRurE2udJOudJOzSdqEiyIocCEtIhcDEkZCQtBCJAghoogoQtyIG3GVbWZqxndmdN5mHO17ufL68s699/x8zn3Oud8YQvSc533u9/nc5zz3Oeedu+cx/6MCAgrsEbBJk1TgMcEiBCIKECwRWWmUYJEBEQUIloisNEqwyICIAgRLRFYaJVhkQEQBgiUiK40SLDIgogDBEpGVRgkWGRBRgGCJyEqjBIsMiChAsERkpVGCRQZEFCBYIrLSKMEiAyIKECwRWWmUYJEBEQUIloisNEqwyICIAgRLRFYaJVhkQEQBgiUiK40SLDIgogDBEpGVRgkWGRBRgGCJyEqjBIsMiChAsERkpVGCRQZEFCBYIrLSaA9gbd+8Nf72O/zgDwxAqQqkAOvRaASMHnz2OX7Wjp/495kXJ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jlurw5Oscwco3dqo9J1iqw5OvcwQr39ip9pxgqQ5Pvs4RrHxjp9pzgqU6PPk6R7DyjZ1qz/8HU+mUpTOprpQAAAAASUVORK5CYII\u003d",
"mime_type": "image/png"
}
],
"line": 9,
"name": "I should be able to connect via JDBC without issues",
"match": {
"location": "JDBCStepDefs.i_should_be_able_to_connect_via_JDBC_without_issues()"
},
"keyword": "Then "
}
]
}
],
"name": "Connectivity",
"description": "As a user I want to be able to connect to the Oracle instance via JDBC",
"id": "connectivity",
"keyword": "Feature",
"uri": "features/Conectivity.feature"
}
]

0 comments on commit 35fab78

Please sign in to comment.