Skip to content

Commit

Permalink
Get current fitnesse output dir from HSAC environment, instead of rel…
Browse files Browse the repository at this point in the history
…ying on constant value in HsacRunner
  • Loading branch information
fhoeben committed Sep 11, 2017
1 parent 5cbe6f8 commit b5f972a
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import fitnesse.junit.FitNessePageAnnotation;
import fitnesse.junit.FitNesseRunner;
import fitnesse.wiki.WikiPage;
import nl.hsac.fitnesse.fixture.Environment;
import nl.hsac.fitnesse.junit.HsacFitNesseRunner;
import org.apache.commons.io.FilenameUtils;
import org.junit.runner.Description;
Expand Down Expand Up @@ -43,6 +44,7 @@ public class JUnitAllureFrameworkListener extends RunListener {
private static final String PAGESOURCE_EXT = "html";
private static final Pattern SCREENSHOT_PATTERN = Pattern.compile("href=\"([^\"]*." + SCREENSHOT_EXT + ")\"");
private static final Pattern PAGESOURCE_PATTERN = Pattern.compile("href=\"([^\"]*." + PAGESOURCE_EXT + ")\"");
private final Environment hsacEnvironment = Environment.getInstance();
private final HashMap<String, String> suites;
private final Label hostLabel;
private final Allure allure;
Expand Down Expand Up @@ -95,18 +97,19 @@ public void testStarted(Description description) {
}

public void testFailure(Failure failure) {
if (failure.getDescription().isTest()) {
Description description = failure.getDescription();
if (description.isTest()) {
Throwable exception = failure.getException();
List<Pattern> patterns = new ArrayList<>();
patterns.add(SCREENSHOT_PATTERN);
patterns.add(PAGESOURCE_PATTERN);
processAttachments(exception, patterns);

this.fireTestCaseFailure(exception);
this.recordTestResult(failure.getDescription());
this.recordTestResult(description);

} else {
this.startFakeTestCase(failure.getDescription());
this.startFakeTestCase(description);
this.fireTestCaseFailure(failure.getException());
this.finishFakeTestCase();
}
Expand Down Expand Up @@ -192,7 +195,7 @@ private void processAttachments(Throwable ex, List<Pattern> patterns) {
for (Pattern pattern : patterns) {
Matcher patternMatcher = pattern.matcher(ex.getMessage());
if (patternMatcher.find()) {
String filePath = HsacFitNesseRunner.FITNESSE_RESULTS_PATH + "/" + patternMatcher.group(1);
String filePath = hsacEnvironment.getFitNesseRootDir() + "/" + patternMatcher.group(1);
String attName;
String type;
String ext = FilenameUtils.getExtension(Paths.get(filePath).toString());
Expand Down

0 comments on commit b5f972a

Please sign in to comment.