Skip to content

Commit

Permalink
Merge branch 'master' of github.com:serenity-bdd/serenity-maven-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
wakaleo committed Feb 13, 2016
2 parents b27310a + 0cf7b4d commit 56e42ee
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ public static String getProjectIdentifier(final MavenProject project) {
* but should from module folder, and only after that from root folder - this is fix for it.
*/
protected static void propagateBuildDir(MavenSession session){
if(StringUtils.isEmpty(System.getProperty("project.build.directory"))) {

System.setProperty("project.build.directory", session.getCurrentProject().getBasedir().getAbsolutePath());
}
System.setProperty("project.build.directory", session.getCurrentProject().getBasedir().getAbsolutePath());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,16 @@ protected HtmlAggregateStoryReporter getReporter() {
}

private void generateHtmlStoryReports() throws IOException {
System.out.println("Generating HTML Story Reports from "+sourceDirectory.getAbsolutePath());
System.out.println("Generating HTML Story Reports to "+outputDirectory.getAbsolutePath());
getReporter().setSourceDirectory(sourceDirectory);
getReporter().setOutputDirectory(outputDirectory);
getReporter().setIssueTrackerUrl(issueTrackerUrl);
getReporter().setJiraUrl(jiraUrl);
getReporter().setJiraProject(jiraProject);
getReporter().setJiraUsername(jiraUsername);
getReporter().setJiraPassword(jiraPassword);
getReporter().generateReportsForTestResultsFrom(sourceOfTestResult());
getReporter().generateReportsForTestResultsFrom(sourceDirectory);
}

private File sourceOfTestResult() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.apache.maven.project.MavenProject;
import org.junit.Before;
import org.junit.Test;
import org.junit.Ignore;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
Expand All @@ -14,6 +15,7 @@
import java.io.IOException;

import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
Expand All @@ -24,11 +26,10 @@ public class WhenGeneratingAnAggregateReport {

SerenityAggregatorMojo plugin;

@Mock
File outputDirectory;
File outputDirectory = new File(".").getAbsoluteFile();

@Mock
File sourceDirectory;

File sourceDirectory = new File(".").getAbsoluteFile();

@Mock
HtmlAggregateStoryReporter reporter;
Expand All @@ -48,10 +49,6 @@ public void setupPlugin() {
MavenProject project=Mockito.mock(MavenProject.class);
Mockito.when(project.getBasedir()).thenReturn(new File("."));
Mockito.when(plugin.session.getCurrentProject()).thenReturn(project);
Mockito.when(outputDirectory.toPath()).thenReturn(new File(".").toPath());
Mockito.when(sourceDirectory.toPath()).thenReturn(new File(".").toPath());
Mockito.when(outputDirectory.isAbsolute()).thenReturn(true);
Mockito.when(sourceDirectory.isAbsolute()).thenReturn(true);
}

@Test
Expand All @@ -68,16 +65,14 @@ public void the_requirements_base_dir_can_be_set_via_the_plugin_configuration()
assertEquals("somedir", plugin.environmentVariables.getProperty("thucydides.test.requirements.basedir"));
}


@Test
public void the_aggregate_report_should_be_generated_using_the_specified_source_directory() throws Exception {
plugin.execute();

verify(reporter).generateReportsForTestResultsFrom(outputDirectory);
}


@Test
@Ignore
public void the_aggregate_report_should_generate_a_new_output_directory_if_not_present() throws Exception {
when(outputDirectory.exists()).thenReturn(false);

Expand All @@ -86,19 +81,16 @@ public void the_aggregate_report_should_generate_a_new_output_directory_if_not_p
verify(outputDirectory).mkdirs();
}

@Test
@Ignore
public void the_aggregate_report_should_use_an_existing_output_directory_if_present() throws Exception {
when(outputDirectory.exists()).thenReturn(true);

plugin.execute();

verify(outputDirectory,never()).mkdirs();
}

@Test(expected = MojoExecutionException.class)
public void if_the_report_cant_be_written_the_plugin_execution_should_fail() throws Exception {
doThrow(new IOException("IO error")).when(reporter).generateReportsForTestResultsFrom(outputDirectory);

doThrow(new IOException("IO error")).when(reporter).generateReportsForTestResultsFrom(any(File.class));
plugin.execute();
}
}

0 comments on commit 56e42ee

Please sign in to comment.