Skip to content
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

Fix RerunLastFailures problem. Appear the perfix only one time #1512

Closed
wants to merge 2 commits into from
Closed
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
7 changes: 6 additions & 1 deletion src/fitnesse/responders/run/SuiteResponder.java
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,12 @@ protected String getRerunPageName() {
PageCrawler pageCrawler = page.getPageCrawler();
WikiPagePath fullPath = pageCrawler.getFullPath();
String fullPathName = PathParser.render(fullPath);
return "RerunLastFailures_"+fullPathName.replace(".","-");
if (fullPathName.startsWith("RerunLastFailures_")) {
String newFullPathName = fullPathName.replace(".", "-");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes more sense to to the replace on line 297 to remove the duplicated code from both branches

return newFullPathName;
} else {
return "RerunLastFailures_" + fullPathName.replace(".", "-");
}
}

protected String getTitle() {
Expand Down
28 changes: 28 additions & 0 deletions test/fitnesse/responders/run/SuiteResponderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@
import fitnesse.util.DateAlteringClock;
import fitnesse.util.DateTimeUtil;
import fitnesse.util.XmlUtil;
import fitnesse.wiki.PageCrawler;
import fitnesse.wiki.PageData;
import fitnesse.wiki.PathParser;
import fitnesse.wiki.WikiPage;
import fitnesse.wiki.WikiPagePath;
import fitnesse.wiki.WikiPageUtil;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
Expand All @@ -36,6 +39,7 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.when;
import static util.RegexTestCase.assertDoesntHaveRegexp;
import static util.RegexTestCase.assertHasRegexp;
import static util.RegexTestCase.assertNotSubString;
Expand All @@ -47,6 +51,8 @@ public class SuiteResponderTest {
private SuiteResponder responder;
private WikiPage root;
private WikiPage suite;
private PageCrawler pageCrawler;
private WikiPagePath wikiPagePath;
private FitNesseContext context;
private final String fitPassFixture = "|!-fitnesse.testutil.PassFixture-!|\n";
private final String fitFailFixture = "|!-fitnesse.testutil.FailFixture-!|\n";
Expand Down Expand Up @@ -564,7 +570,29 @@ public void loadsCustomFormatters() throws Exception {

assertTrue(FooFormatter.initialized);
}

fhoeben marked this conversation as resolved.
Show resolved Hide resolved
@Test
public void testGetRerunPageName_withRerunPrefix() {

String fullPathName = "RerunLastFailures_SomePage";
when(PathParser.render(wikiPagePath)).thenReturn(fullPathName);

String result = responder.getRerunPageName();

assertEquals("RerunLastFailures_SomePage".replace(".", "-"), result);
fhoeben marked this conversation as resolved.
Show resolved Hide resolved
}

@Test
public void testGetRerunPageName_withoutRerunPrefix() {

String fullPathName = "SomeOtherPage";
when(PathParser.render(wikiPagePath)).thenReturn(fullPathName);

String result = responder.getRerunPageName();

assertEquals("RerunLastFailures_SomeOtherPage".replace(".", "-"), result);
fhoeben marked this conversation as resolved.
Show resolved Hide resolved
}

private String runSuite() throws Exception {
Response response = responder.makeResponse(context, request);

Expand Down
Loading