forked from serenity-bdd/serenity-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved the ant plugin over to the new Serenity namespace
- Loading branch information
Showing
12 changed files
with
166 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
serenity-ant-task/src/main/java/net/serenity_bdd/ant/SerenityReportingTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
package net.serenity_bdd.ant; | ||
|
||
import net.serenity_bdd.ant.util.PathProcessor; | ||
import net.thucydides.core.reports.html.HtmlAggregateStoryReporter; | ||
import org.apache.tools.ant.BuildException; | ||
import org.apache.tools.ant.Task; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
public class SerenityReportingTask extends Task { | ||
|
||
/** | ||
* Aggregate reports are generated here | ||
*/ | ||
public String outputDirectory; | ||
|
||
/** | ||
* Serenity test reports are read from here | ||
*/ | ||
public String sourceDirectory; | ||
|
||
/** | ||
* URL of the issue tracking system to be used to generate links for issue numbers. | ||
*/ | ||
public String issueTrackerUrl; | ||
|
||
/** | ||
* Base URL for JIRA, if you are using JIRA as your issue tracking system. | ||
* If you specify this property, you don't need to specify the issueTrackerUrl. | ||
*/ | ||
public String jiraUrl; | ||
public String jiraUsername; | ||
public String jiraPassword; | ||
|
||
/** | ||
* JIRA project key, which will be prepended to the JIRA issue numbers. | ||
*/ | ||
public String jiraProject; | ||
|
||
private PathProcessor pathProcessor = new PathProcessor(); | ||
|
||
public Path getSourceDirectoryFile() { | ||
return Paths.get(pathProcessor.normalize(sourceDirectory)); | ||
} | ||
|
||
public void setSourceDirectory(String sourceDirectory) { | ||
this.sourceDirectory = sourceDirectory; | ||
} | ||
|
||
public void setOutputDirectory(String outputDirectory) { | ||
this.outputDirectory = outputDirectory; | ||
|
||
} | ||
|
||
public void setIssueTrackerUrl(String issueTrackerUrl) { | ||
this.issueTrackerUrl = issueTrackerUrl; | ||
} | ||
|
||
public void setJiraUrl(String jiraUrl) { | ||
this.jiraUrl = jiraUrl; | ||
} | ||
|
||
public void setJiraUsername(String jiraUsername) { | ||
this.jiraUsername = jiraUsername; | ||
} | ||
|
||
public void setJiraPassword(String jiraPassword) { | ||
this.jiraPassword = jiraPassword; | ||
} | ||
|
||
public void setJiraProject(String jiraProject) { | ||
this.jiraProject = jiraProject; | ||
} | ||
|
||
private String normalizedPath(String directoryPath) { | ||
return pathProcessor.normalize(directoryPath); | ||
} | ||
|
||
public Path getOutputDirectoryFile() { | ||
return Paths.get(normalizedPath(outputDirectory)); | ||
} | ||
|
||
|
||
|
||
public void execute() { | ||
log("Generating Serenity reports"); | ||
|
||
|
||
try { | ||
prepareDirectories(); | ||
|
||
HtmlAggregateStoryReporter reporter = new HtmlAggregateStoryReporter(getProject().getName()); | ||
reporter.setSourceDirectory(getSourceDirectoryFile().toFile()); | ||
reporter.setOutputDirectory(getOutputDirectoryFile().toFile()); | ||
reporter.setIssueTrackerUrl(issueTrackerUrl); | ||
reporter.setJiraUrl(jiraUrl); | ||
reporter.setJiraProject(jiraProject); | ||
reporter.setJiraUsername(jiraUsername); | ||
reporter.setJiraPassword(jiraPassword); | ||
reporter.generateReportsForTestResultsFrom(sourceOfTestResult().toFile()); | ||
} catch (IOException e) { | ||
throw new BuildException(e); | ||
} | ||
} | ||
|
||
private void prepareDirectories() throws IOException { | ||
if (Files.notExists(getOutputDirectoryFile())) { | ||
Files.createDirectories(getOutputDirectoryFile()); | ||
} | ||
|
||
} | ||
|
||
private Path sourceOfTestResult() { | ||
if ((getSourceDirectoryFile() != null) && (Files.exists(getSourceDirectoryFile()))) { | ||
return getSourceDirectoryFile(); | ||
} else { | ||
return getOutputDirectoryFile(); | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...et/thucydides/ant/util/PathProcessor.java → .../serenity_bdd/ant/util/PathProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package net.thucydides.ant.util; | ||
package net.serenity_bdd.ant.util; | ||
|
||
|
||
import java.net.URISyntaxException; | ||
|
120 changes: 7 additions & 113 deletions
120
serenity-ant-task/src/main/java/net/thucydides/ant/ThucydidesReportingTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,123 +1,17 @@ | ||
package net.thucydides.ant; | ||
|
||
import net.thucydides.ant.util.PathProcessor; | ||
import net.serenity_bdd.ant.SerenityReportingTask; | ||
import net.serenity_bdd.ant.util.PathProcessor; | ||
import net.thucydides.core.reports.html.HtmlAggregateStoryReporter; | ||
import org.apache.tools.ant.BuildException; | ||
import org.apache.tools.ant.Task; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
public class ThucydidesReportingTask extends Task { | ||
|
||
/** | ||
* Aggregate reports are generated here | ||
*/ | ||
public String outputDirectory; | ||
|
||
/** | ||
* Thucydides test reports are read from here | ||
*/ | ||
public String sourceDirectory; | ||
|
||
/** | ||
* URL of the issue tracking system to be used to generate links for issue numbers. | ||
*/ | ||
public String issueTrackerUrl; | ||
|
||
/** | ||
* Base URL for JIRA, if you are using JIRA as your issue tracking system. | ||
* If you specify this property, you don't need to specify the issueTrackerUrl. | ||
*/ | ||
public String jiraUrl; | ||
public String jiraUsername; | ||
public String jiraPassword; | ||
|
||
/** | ||
* JIRA project key, which will be prepended to the JIRA issue numbers. | ||
*/ | ||
public String jiraProject; | ||
|
||
private PathProcessor pathProcessor = new PathProcessor(); | ||
|
||
public Path getSourceDirectoryFile() { | ||
return Paths.get(pathProcessor.normalize(sourceDirectory)); | ||
} | ||
|
||
public void setSourceDirectory(String sourceDirectory) { | ||
this.sourceDirectory = sourceDirectory; | ||
} | ||
|
||
public void setOutputDirectory(String outputDirectory) { | ||
this.outputDirectory = outputDirectory; | ||
|
||
} | ||
|
||
public void setIssueTrackerUrl(String issueTrackerUrl) { | ||
this.issueTrackerUrl = issueTrackerUrl; | ||
} | ||
|
||
public void setJiraUrl(String jiraUrl) { | ||
this.jiraUrl = jiraUrl; | ||
} | ||
|
||
public void setJiraUsername(String jiraUsername) { | ||
this.jiraUsername = jiraUsername; | ||
} | ||
|
||
public void setJiraPassword(String jiraPassword) { | ||
this.jiraPassword = jiraPassword; | ||
} | ||
|
||
public void setJiraProject(String jiraProject) { | ||
this.jiraProject = jiraProject; | ||
} | ||
|
||
private String normalizedPath(String directoryPath) { | ||
return pathProcessor.normalize(directoryPath); | ||
} | ||
|
||
public Path getOutputDirectoryFile() { | ||
return Paths.get(normalizedPath(outputDirectory)); | ||
} | ||
|
||
|
||
|
||
public void execute() { | ||
log("Generating Thucydides reports"); | ||
|
||
|
||
try { | ||
prepareDirectories(); | ||
|
||
HtmlAggregateStoryReporter reporter = new HtmlAggregateStoryReporter(getProject().getName()); | ||
reporter.setSourceDirectory(getSourceDirectoryFile().toFile()); | ||
reporter.setOutputDirectory(getOutputDirectoryFile().toFile()); | ||
reporter.setIssueTrackerUrl(issueTrackerUrl); | ||
reporter.setJiraUrl(jiraUrl); | ||
reporter.setJiraProject(jiraProject); | ||
reporter.setJiraUsername(jiraUsername); | ||
reporter.setJiraPassword(jiraPassword); | ||
reporter.generateReportsForTestResultsFrom(sourceOfTestResult().toFile()); | ||
} catch (IOException e) { | ||
throw new BuildException(e); | ||
} | ||
} | ||
|
||
private void prepareDirectories() throws IOException { | ||
if (Files.notExists(getOutputDirectoryFile())) { | ||
Files.createDirectories(getOutputDirectoryFile()); | ||
} | ||
|
||
} | ||
|
||
private Path sourceOfTestResult() { | ||
if ((getSourceDirectoryFile() != null) && (Files.exists(getSourceDirectoryFile()))) { | ||
return getSourceDirectoryFile(); | ||
} else { | ||
return getOutputDirectoryFile(); | ||
} | ||
} | ||
} | ||
/** | ||
* Use SerenityReportingTask instead. | ||
*/ | ||
@Deprecated | ||
public class ThucydidesReportingTask extends SerenityReportingTask {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...thucydides/ant/WhenRunningTheAntTask.java → ...renity_bdd/ant/WhenRunningTheAntTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
package net.thucydides.ant; | ||
package net.serenity_bdd.ant; | ||
|
||
import java.net.URISyntaxException; | ||
import java.nio.file.Paths; | ||
|
||
import static java.lang.Thread.currentThread; | ||
|
||
public class WhenRunningTheAntTask extends ThucydidesAntTaskTestBase { | ||
public class WhenRunningTheAntTask extends SerenityAntTaskTestBase { | ||
public void setUp() throws Exception { | ||
String antFile = Paths.get(currentThread().getContextClassLoader().getResource("build.xml").toURI()).toString();//currentThread().getContextClassLoader().getResource("build.xml").getFile(); | ||
configureProject(antFile); | ||
cleanReportsIn("test-outcomes"); | ||
} | ||
|
||
public void testShouldExecuteTaskWithDefaultValues() throws URISyntaxException { | ||
executeTarget("thucydides.reports"); | ||
thucydidesReportsShouldAppearIn("test-outcomes"); | ||
executeTarget("serenity.reports"); | ||
serenityReportsShouldAppearIn("test-outcomes"); | ||
thucydidesResourcesShouldAppearIn("test-outcomes"); | ||
} | ||
} |
8 changes: 4 additions & 4 deletions
8
...eAntTaskForADifferentOutputDirectory.java → ...eAntTaskForADifferentOutputDirectory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
package net.thucydides.ant; | ||
package net.serenity_bdd.ant; | ||
|
||
import java.net.URISyntaxException; | ||
|
||
import static java.lang.Thread.currentThread; | ||
|
||
public class WhenRunningTheAntTaskForADifferentOutputDirectory extends ThucydidesAntTaskTestBase { | ||
public class WhenRunningTheAntTaskForADifferentOutputDirectory extends SerenityAntTaskTestBase { | ||
public void setUp() throws Exception { | ||
String antFile = currentThread().getContextClassLoader().getResource("build-different-output.xml").getFile(); | ||
configureProject(antFile); | ||
cleanReportsIn("alt-test-outcomes"); | ||
} | ||
|
||
public void testShouldExecuteTaskWithDefaultValues() throws URISyntaxException { | ||
executeTarget("thucydides.reports"); | ||
thucydidesReportsShouldAppearIn("alt-test-outcomes"); | ||
executeTarget("serenity.reports"); | ||
serenityReportsShouldAppearIn("alt-test-outcomes"); | ||
} | ||
} |
8 changes: 4 additions & 4 deletions
8
.../WhenRunningTheAntTaskWithJiraConfig.java → .../WhenRunningTheAntTaskWithJiraConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
package net.thucydides.ant; | ||
package net.serenity_bdd.ant; | ||
|
||
import java.net.URISyntaxException; | ||
|
||
import static java.lang.Thread.currentThread; | ||
|
||
public class WhenRunningTheAntTaskWithJiraConfig extends ThucydidesAntTaskTestBase { | ||
public class WhenRunningTheAntTaskWithJiraConfig extends SerenityAntTaskTestBase { | ||
public void setUp() { | ||
String antFile = currentThread().getContextClassLoader().getResource("build-with-jira-authentication.xml").getFile(); | ||
configureProject(antFile); | ||
} | ||
|
||
public void testShouldExecuteTaskWithJIRAConfiguration() throws URISyntaxException { | ||
executeTarget("thucydides.reports"); | ||
thucydidesReportsShouldAppearIn("test-outcomes"); | ||
executeTarget("serenity.reports"); | ||
serenityReportsShouldAppearIn("test-outcomes"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.