Skip to content

This pull has both the enabled check box and a hack to allow test suite field to use params #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 44 additions & 6 deletions src/main/java/hudson/plugins/seleniumhq/SeleniumhqBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,30 @@ public class SeleniumhqBuilder extends Builder {
private final String suiteFile;
private final String resultFile;
private final String other;
private final boolean testEnabled;


@DataBoundConstructor
public SeleniumhqBuilder(String browser, String startURL, String suiteFile, String resultFile,
String other) {
String other, boolean testEnabled) {
this.browser = browser;
this.startURL = startURL;
this.suiteFile = suiteFile;
this.resultFile = resultFile;
this.other = other;
this.testEnabled = testEnabled;
}

//Left this call in to satisfy the tests. Did not change the tests.
public SeleniumhqBuilder(String browser, String startURL, String suiteFile, String resultFile,
String other) {
this.browser = browser;
this.startURL = startURL;
this.suiteFile = suiteFile;
this.resultFile = resultFile;
this.other = other;
this.testEnabled = true;
}
/**
* We'll use this from the <tt>config.jelly</tt>.
*/
Expand Down Expand Up @@ -91,6 +104,13 @@ public String getResultFile() {
return resultFile;
}

/**
* We'll use this from the <tt>config.jelly</tt>.
*/
public boolean getTestEnabled() {
return testEnabled;
}

/**
* Check if the suiteFile is a URL
*
Expand All @@ -113,7 +133,7 @@ public boolean isURLSuiteFile() {
* @throws IOException
*/
public boolean isFileSuiteFile(AbstractBuild<?,?> build, Launcher launcher) throws IOException, InterruptedException {
FilePath suiteFilePath = new FilePath(build.getWorkspace(), this.suiteFile);
FilePath suiteFilePath = new FilePath(build.getWorkspace(), this.suiteFile);
if (suiteFilePath.exists())
{
return suiteFilePath.isDirectory() == false;
Expand Down Expand Up @@ -142,6 +162,18 @@ public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListene
return false;
}

//if test is not enabled we should mark it as NOT BUILT (rather than success or failure
if(!this.getTestEnabled()) {
listener.getLogger().println("---------------");
listener.getLogger().println("SKIPPING: Test Suite. '" + this.getSuiteFile() + "' was marked as not enabled");
listener.getLogger().println("---------------");
//Let the other surrounding tests determine the build result
//build.setResult(Result.NOT_BUILT);

//return build so build doesn't get aborted & other tests will get run
return true;
}

// -------------------------------
// Check projet config
// -------------------------------
Expand Down Expand Up @@ -188,7 +220,7 @@ else if (this.isURLSuiteFile())
{
File localWorkspace = new File(build.getRootDir(), "workspace");
File tempSuiteLocal = localWorkspace.createTempFile("tempHtmlSuite", "html");

listener.getLogger().println("Try downloading suite file on master");
listener.getLogger().println(" from url : " + this.suiteFile );
listener.getLogger().println(" to file : " + tempSuiteLocal.getPath());
Expand All @@ -214,9 +246,15 @@ else if (this.isURLSuiteFile())
return false;
}
}
else
//see if we've got a jenkins variable. if so just pass it along
else if (this.suiteFile.startsWith("$"))
{
// The suiteFile it is a unsuported type
listener.getLogger().println("Suite File Looks Like a Parameter: "+ this.suiteFile);
suiteFile = this.suiteFile;
}
else
{
// The suiteFile it is a unsuported type
listener.error("The suiteFile is not a file or an url ! Check your build configuration.");
build.setResult(Result.FAILURE);
return false;
Expand All @@ -242,7 +280,7 @@ else if (this.isURLSuiteFile())
cmd.add(this.getStartURL());
cmd.add(suiteFile);
cmd.add(resultFile);

try
{
String javaCmdString = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

See global.jelly for a general discussion about jelly script.
-->
<f:entry title="Enabled" help="${rootURL}/plugin/seleniumhq/help-builder-testEnabled.html">
<f:checkbox field="testEnabled" checked="${instance.testEnabled}" default="true" />
</f:entry>
<f:entry title="browser" help="${rootURL}/plugin/seleniumhq/help-builder-browser.html">
<f:textbox field="browser" clazz="required" checkMessage="${%mandatory.browser}"/>
</f:entry>
Expand Down