Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

preparing next FitNesse release

  • Loading branch information...
commit f971dcc32533c0697d0c9095d63fddd2713c27e5 1 parent 21066cc
@mgaertne mgaertne authored
View
11 FitNesseRoot/FitNesse/UserGuide/AdministeringFitnesse/properties.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<properties>
+ <Edit>true</Edit>
+ <Files>true</Files>
+ <Properties>true</Properties>
+ <RecentChanges>true</RecentChanges>
+ <Refactor>true</Refactor>
+ <Search>true</Search>
+ <Versions>true</Versions>
+ <WhereUsed>true</WhereUsed>
+</properties>
View
2  FitNesseRoot/FrontPage/content.txt
@@ -10,4 +10,4 @@ To add your first "page", click the [[Edit][FrontPage?edit]] button and add a [[
| [[User Guide][FitNesse.UserGuide]]|''Answer the rest of your questions here.''|
| [[Acceptance Tests][FitNesse.SuiteAcceptanceTests]]|''FitNesse's suite of Acceptance Tests''|
-!note Release v20111023
+!note Release v20111024
View
62 FitNesseRoot/files/templates/suiteOverview.vm
@@ -0,0 +1,62 @@
+#set ($page_title="Suite Overview")
+#parse("pageHead.vm")
+
+#if($treeRoot)
+ #set ($branch=$treeRoot)
+ #if ($branch.branches.size()==1)
+ #set ($branch=$branch.getBranches().get(0))
+ <div class="overview_overview">
+ <h2>Results Summary</h2>
+ <div class="overview_results">
+ <table>
+ <tr>
+ <td colspan="4">
+ <div class="overview_bar">
+ <div style="width: $branch.getPassedPercent()%;" class="pass overview_part"></div>
+ <div style="width: $branch.getUnrunPercent()%;" class="unrun overview_part"></div>
+ <div style="width: $branch.getFailedPercent()%;" class="fail overview_part"></div>
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <td class="passed_tests"/>
+ <td>$branch.getTestsPassed() </td>
+ <td>($branch.getPassedPercent()%)</td>
+ <td> Test(s) Passed </td>
+ </tr>
+ <tr>
+ <td class="unrun_tests"/>
+ <td>$branch.getTestsUnrun()</td>
+ <td>($branch.getUnrunPercent()%)</td>
+ <td> Test(s) Not Run </td>
+ </tr>
+ <tr>
+ <td class="failed_tests"/>
+ <td> $branch.getTestsFailed() </td>
+ <td> ($branch.getFailedPercent()%)</td>
+ <td>Test(s) Failed </td>
+ </tr>
+ </table>
+ </div>
+ </div>
+ <div>
+ <h2>Detailed Results</h2>
+ <span class="meta $branch.getCssClass()">$branch.getName()</span>
+ <span>
+ (<a href="javascript:expandAll();">Expand</a> |
+ <a href="javascript:collapseAll();">Collapse</a>)
+ </span>
+
+
+ <div>
+ #parse("suiteOverviewNode.vm")
+ </div>
+ </div>
+ #else
+ #parse("suiteOverviewNode.vm")
+ #end
+#else
+ <h2>Sorry no information: $pageTitle.Title</h2>
+#end
+
+#parse("pageFooter.vm")
View
27 FitNesseRoot/files/templates/suiteOverviewNode.vm
@@ -0,0 +1,27 @@
+#foreach($branch in $branch.getBranches())
+ #if ($branch.isTest())
+ <div class="completion_test"><a href="$branch.getHistoryUrl()" class="$branch.getCssClass()">$branch.getName()</a></div>
+ #else
+
+ <div>
+ <a href="javascript:toggleCollapsable('$branch.getFullName()');">
+ <img id="img$branch.getFullName()" class="left" src="/files/images/collapsableClosed.gif">
+ </a>
+ <div class="meta completion_folder"><span class="$branch.getCssClass()"> <a href="$branch.getHistoryUrl()" class="$branch.getCssClass()">$branch.getName()</a></span> (
+ #if ($branch.getTestsPassed() != 0)
+ <span class="passed_tests"> $branch.getTestsPassed() &nbsp; $branch.getPassedPercentString()</span>
+ #end
+ #if ($branch.getTestsUnrun() != 0)
+ <span class="unrun_tests">$branch.getTestsUnrun() &nbsp; $branch.getUnrunPercentString()</span>
+ #end
+ #if ($branch.getTestsFailed() != 0)
+ <span class="failed_tests">$branch.getTestsFailed() &nbsp; $branch.getFailedPercentString()</span>
+ #end
+ )
+ </div>
+ <div id="$branch.getFullName()" class="hidden">
+ #parse("suiteOverviewNode.vm")
+ </div>
+ </div>
+ #end
+#end
View
4 FitNesseRoot/properties
@@ -4,6 +4,6 @@ PropertiesToXmlUpdate=applied
FilesAttributeUpdate=applied
SymLinkPropertyFormatUpdate=applied
VirtualWikiDeprecationUpdate=applied
-Version=v20111023
-WhereUsedAttributeUpdate=applied
+Version=v20111024
RecentChangesAttributeUpdate=applied
+WhereUsedAttributeUpdate=applied
View
2  pom.xml
@@ -7,7 +7,7 @@
<description> The fully integrated standalone wiki, and acceptance
testing framework. </description>
<url>http://fitnesse.org</url>
- <version>20111023</version>
+ <version>20111024</version>
<licenses>
<license>
<name>GNU Public License, Version 2.0</name>
View
2  src/fitnesse/FitNesseVersion.java
@@ -10,7 +10,7 @@
private final String version;
public FitNesseVersion() {
- this("v20111023");
+ this("v20111024");
}
public FitNesseVersion(String version) {
View
31 src/fitnesse/responders/testHistory/MostRecentPageHistoryReader.java
@@ -0,0 +1,31 @@
+package fitnesse.responders.testHistory;
+
+import java.io.File;
+import java.text.ParseException;
+
+public class MostRecentPageHistoryReader extends PageHistoryReader {
+
+ TestResultRecord mostRecentRecord = null;
+ File directory = null;
+
+ public MostRecentPageHistoryReader(File pageDirectory) {
+ directory = pageDirectory;
+ }
+
+ public TestResultRecord findMostRecentTestRun() {
+ try {
+ readHistoryFromPageDirectory(directory);
+ } catch (ParseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return mostRecentRecord;
+ }
+
+ @Override
+ void processTestFile(TestResultRecord record) throws ParseException {
+ if (mostRecentRecord == null || mostRecentRecord.getDate().compareTo(record.getDate()) < 0) {
+ mostRecentRecord = record;
+ }
+ }
+}
View
70 src/fitnesse/responders/testHistory/PageHistoryReader.java
@@ -0,0 +1,70 @@
+package fitnesse.responders.testHistory;
+
+import java.io.File;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import fitnesse.FitNesseContext;
+import fitnesse.responders.run.TestSummary;
+import fitnesse.wiki.WikiPage;
+
+import util.FileUtil;
+
+public class PageHistoryReader {
+
+ private SimpleDateFormat dateFormat = new SimpleDateFormat(TestHistory.TEST_RESULT_FILE_DATE_PATTERN);
+ public static final String TEST_FILE_FORMAT = "\\A\\d{14}_\\d+_\\d+_\\d+_\\d+(.xml)*\\Z";
+
+ void readHistoryFromPageDirectory(File pageDirectory) throws ParseException {
+ File[] resultDir = FileUtil.getDirectoryListing(pageDirectory);
+
+ for (File file : resultDir) {
+ if (fileIsNotADirectoryAndIsValid(file)) {
+ compileResultFileIntoHistory(file);
+ }
+ }
+ }
+
+ private boolean fileIsNotADirectoryAndIsValid(File file) {
+ if(file.isDirectory())
+ return false;
+ if(!matchesPageHistoryFileFormat(file.getName()))
+ return false;
+ return true;
+
+ }
+
+ public static boolean matchesPageHistoryFileFormat(String pageHistoryFileName) {
+ return pageHistoryFileName.matches(TEST_FILE_FORMAT);
+ }
+
+ private void compileResultFileIntoHistory(File file) throws ParseException {
+ TestResultRecord record = buildTestResultRecord(file);
+ processTestFile(record);
+ }
+
+ void processTestFile(TestResultRecord record) throws ParseException {
+ // for subclasses.
+ }
+
+ private TestResultRecord buildTestResultRecord(File file) throws ParseException {
+ String parts[] = file.getName().split("_|\\.");
+ Date date = dateFormat.parse(parts[0]);
+ TestResultRecord testResultRecord = new TestResultRecord(
+ file,
+ date,
+ Integer.parseInt(parts[1]),
+ Integer.parseInt(parts[2]),
+ Integer.parseInt(parts[3]),
+ Integer.parseInt(parts[4]));
+ return testResultRecord;
+ }
+
+ public static String makePageHistoryFileName(FitNesseContext context, WikiPage page, TestSummary counts, long time) throws Exception {
+ return String.format("%s/%s/%s",
+ context.getTestHistoryDirectory(),
+ page.getPageCrawler().getFullPath(page).toString(),
+ TestHistory.makeResultFileName(counts, time));
+ }
+}
View
60 src/fitnesse/responders/testHistory/SuiteOverviewResponder.java
@@ -0,0 +1,60 @@
+package fitnesse.responders.testHistory;
+
+import java.io.StringWriter;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.List;
+
+import javax.swing.text.DateFormatter;
+
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+
+import fitnesse.FitNesseContext;
+import fitnesse.Responder;
+import fitnesse.VelocityFactory;
+import fitnesse.authentication.SecureOperation;
+import fitnesse.authentication.SecureResponder;
+import fitnesse.html.HtmlPage;
+import fitnesse.html.HtmlUtil;
+import fitnesse.http.Request;
+import fitnesse.http.Response;
+import fitnesse.http.SimpleResponse;
+import fitnesse.responders.run.SuiteContentsFinder;
+import fitnesse.responders.run.SuiteFilter;
+import fitnesse.responders.templateUtilities.PageTitle;
+import fitnesse.wiki.PathParser;
+import fitnesse.wiki.WikiPage;
+
+public class SuiteOverviewResponder implements Responder {
+
+ public Response makeResponse(FitNesseContext context, Request request) throws Exception {
+ WikiPage root = context.root;
+ WikiPage page = root.getPageCrawler().getPage(root, PathParser.parse(request.getResource()));
+
+ SuiteFilter filter = new SuiteFilter(request, page.getPageCrawler().getFullPath(page).toString());
+ SuiteContentsFinder suiteTestFinder = new SuiteContentsFinder(page, filter, root);
+
+ List<WikiPage> pagelist = suiteTestFinder.makePageList();
+ SuiteOverviewTree treeview = new SuiteOverviewTree(pagelist);
+ treeview.findLatestResults(context.getTestHistoryDirectory());
+ treeview.countResults();
+
+ SimpleResponse response = new SimpleResponse(400);
+
+ VelocityContext velocityContext = new VelocityContext();
+ velocityContext.put("treeRoot", treeview.getTreeRoot());
+ PageTitle title = new PageTitle("Suite Overview", PathParser.parse(request.getResource()));
+ velocityContext.put("pageTitle", title);
+
+
+
+ String velocityTemplate = "suiteOverview.vm";
+ Template template = VelocityFactory.getVelocityEngine().getTemplate(velocityTemplate);
+ StringWriter writer = new StringWriter();
+ template.merge(velocityContext, writer);
+ response.setContent(writer.toString());
+ return response;
+
+ }
+}
View
292 src/fitnesse/responders/testHistory/SuiteOverviewTree.java
@@ -0,0 +1,292 @@
+package fitnesse.responders.testHistory;
+
+import java.io.File;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.LinkedList;
+import java.util.List;
+
+import util.GracefulNamer;
+
+import fitnesse.wiki.WikiPage;
+
+public class SuiteOverviewTree {
+
+ private TreeItem treeRoot = new TreeItem("root", "");
+
+ SuiteOverviewTree(List<String> aPagelist, String anotherone) {
+ makeTree(aPagelist);
+ }
+
+ public SuiteOverviewTree(List<WikiPage> wikiPagelist) {
+ this(convertToPageList(wikiPagelist), null);
+ }
+
+ private void makeTree(List<String> pageList) {
+ for (String pageName : pageList)
+ {
+ String[] splits = pageName.split("\\.");
+ treeRoot.addItem(splits, 0);
+ }
+ compactTree();
+ }
+
+ public TreeItem getTreeRoot() {
+ return treeRoot;
+ }
+
+ private static List<String> convertToPageList(List<WikiPage> wikiPagelist) {
+ List<String> allPages = new LinkedList<String>();
+
+ for (WikiPage aPage : wikiPagelist) {
+ try {
+ allPages.add(aPage.getPageCrawler().getFullPath(aPage).toString());
+ } catch (Exception e) {
+ allPages.add("There was also a probem getting the path of one page.");
+ }
+ }
+ return allPages;
+ }
+
+ public void countResults() {
+ RecursiveTreeMethod countResults = new RecursiveTreeMethod() {
+ @Override
+ public boolean shouldDoItemBeforeBranches() {
+ return false;
+ }
+
+ @Override
+ public void doMethod(TreeItem item) {
+ item.calculateResults();
+ }
+ };
+ treeRoot.doRecursive(countResults, 0);
+ }
+
+ public void findLatestResults(final File historyDirectory) {
+ RecursiveTreeMethod findLatestResult = new RecursiveTreeMethod() {
+ @Override
+ public void doMethod(TreeItem item) {
+ if (item.isTest()) {
+ File directory = new File(historyDirectory, item.fullName);
+ MostRecentPageHistoryReader reader = new MostRecentPageHistoryReader(directory);
+ item.result = reader.findMostRecentTestRun();
+ }
+ }
+ };
+ treeRoot.doRecursive(findLatestResult, 0);
+ }
+
+ private void compactTree() {
+ RecursiveTreeMethod compactBranch = new RecursiveTreeMethod() {
+ @Override
+ public void doMethod(TreeItem item) {
+ item.compactWithChildIfOnlyOneChild();
+ }
+ };
+ treeRoot.doRecursive(compactBranch, 0);
+
+ }
+
+ private SimpleDateFormat dateFormatter = new SimpleDateFormat(TestHistory.TEST_RESULT_FILE_DATE_PATTERN);
+
+ public class TreeItem
+ {
+
+ private String name;
+ private String fullName;
+ int testsPassed = 0;
+ int testsUnrun = 0;
+ int testsFailed = 0;
+
+ List<TreeItem> branches = new LinkedList<TreeItem>();
+ TestResultRecord result = null;
+
+
+
+ public int getTestsPassed() {
+ return testsPassed;
+ }
+
+ public int getTestsUnrun() {
+ return testsUnrun;
+ }
+
+ public int getTestsFailed() {
+ return testsFailed;
+ }
+
+ private double calcPercentOfTotalTests(int value) {
+ int totalTests = testsPassed + testsUnrun + testsFailed;
+ double doubleValue = value;
+ return ((double)(Math.round(((1000.0 * value)/totalTests))))/10;
+ }
+
+ private String makePercentageOfTotalString(int value) {
+ double percentage = calcPercentOfTotalTests(value);
+ if (calcPercentOfTotalTests(value) < 99.95) {
+ return "(" + (int)percentage + "%)";
+ }
+ return "";
+ }
+
+ public String getPassedPercentString() {
+ return makePercentageOfTotalString(testsPassed);
+ }
+
+ public String getUnrunPercentString() {
+ return makePercentageOfTotalString(testsUnrun);
+ }
+
+ public String getFailedPercentString() {
+ return makePercentageOfTotalString(testsFailed);
+ }
+
+ public double getPassedPercent() {
+ return calcPercentOfTotalTests(testsPassed);
+ }
+
+ public double getUnrunPercent() {
+ return calcPercentOfTotalTests(testsUnrun);
+ }
+
+ public double getFailedPercent() {
+ return calcPercentOfTotalTests(testsFailed);
+ }
+
+
+ public String getName() {
+ return GracefulNamer.regrace(name);
+ }
+
+ public String getFullName() {
+ return fullName;
+ }
+
+ public String getHistoryUrl() {
+ String url = getFullName();
+
+ if (result != null) {
+ url += "?pageHistory&resultDate=";
+ url += dateFormatter.format(result.getDate());
+ }
+
+ return url;
+ }
+
+ public void compactWithChildIfOnlyOneChild() {
+ if (branches.size() == 1) {
+ TreeItem child = branches.get(0);
+ if (!child.isTest()) {
+ name += "." + child.name;
+ fullName += "." + child.name;
+ branches = child.branches;
+
+ compactWithChildIfOnlyOneChild();
+ }
+ }
+ }
+
+ TreeItem(String branchName, String branchFullName) {
+ name = branchName;
+ fullName = branchFullName;
+ }
+
+ public List<TreeItem> getBranches() {
+ return branches;
+ }
+
+ public void calculateResults() {
+ testsPassed = 0;
+ testsUnrun = 0;
+ testsFailed = 0;
+
+ if (isTest()) {
+ if (result == null) {
+ testsUnrun++;
+ }
+ else if ((result.getExceptions() == 0) && (result.getWrong() == 0)) {
+ testsPassed++;
+ }
+ else {
+ testsFailed++;
+ }
+ }
+ else {
+ for (TreeItem branch : branches) {
+ testsUnrun += branch.testsUnrun;
+ testsPassed += branch.testsPassed;
+ testsFailed += branch.testsFailed;
+ }
+ }
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+
+ void addItem(String[] itemPath, int currentIndex) {
+ if (currentIndex < itemPath.length) {
+ //special case for this tree only, that all the titles should be organised before we start.
+ if (nameSameAsLastName(itemPath[currentIndex])) {
+ branches.get(branches.size() - 1).addItem(itemPath, ++currentIndex);
+ }
+ else {
+ String branchName = itemPath[currentIndex];
+ String branchFullName = fullName;
+ branchFullName += (fullName.length() > 0) ? "." + branchName : branchName;
+ TreeItem branch = new TreeItem(branchName, branchFullName);
+ branches.add(branch);
+ branch.addItem(itemPath, ++currentIndex);
+ }
+ }
+ }
+
+ private boolean nameSameAsLastName(String currentName) {
+ return !branches.isEmpty() && branches.get(branches.size() - 1).name.equals(currentName);
+ }
+
+ public boolean isTest() {
+ return (branches.size() == 0);
+ }
+
+ public String getCssClass() {
+ if (testsFailed != 0) {
+ return "fail";
+ }
+ else if (testsUnrun != 0) {
+ return "unrun";
+ }
+ else {
+ return "done";
+ }
+ }
+
+ void doRecursive(RecursiveTreeMethod method, int level) {
+ if (method.shouldDoItemBeforeBranches() && (level != 0)) {
+ method.doMethod(this);
+ }
+
+ for (TreeItem branch : branches) {
+ branch.doRecursive(method, level + 1);
+ }
+
+ if (!method.shouldDoItemBeforeBranches() && (level != 0)) {
+ method.doMethod(this);
+ }
+ }
+ }
+
+ abstract class RecursiveTreeMethod
+ {
+ public boolean shouldDoItemBeforeBranches()
+ {
+ return true;
+ }
+
+ public abstract void doMethod(TreeItem item);
+
+ }
+}
+
View
34 src/fitnesse/responders/testHistory/SuiteOverviewTreeTest.java
@@ -0,0 +1,34 @@
+package fitnesse.responders.testHistory;
+
+import java.util.LinkedList;
+
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
+public class SuiteOverviewTreeTest {
+
+
+ @SuppressWarnings("deprecation")
+ @Test
+ public void testTestsInSameDirectoryAppearOnSameLevel() {
+ LinkedList<String> pageNames = new LinkedList<String>();
+ pageNames.add("FitNesse.MyTests.Test1");
+ pageNames.add("FitNesse.MyTests.Test2");
+ pageNames.add("FitNesse.MyTests.Test3");
+
+ SuiteOverviewTree tree = new SuiteOverviewTree(pageNames, null);
+
+ }
+
+ @SuppressWarnings("deprecation")
+ @Test
+ public void testTestsInDiffDirectoryAreSplit() {
+ LinkedList<String> pageNames = new LinkedList<String>();
+ pageNames.add("FitNesse.MyTestsA.Test1");
+ pageNames.add("FitNesse.MyTestsA.Test2");
+ pageNames.add("FitNesse.MyTestsB.Test3");
+
+ SuiteOverviewTree tree = new SuiteOverviewTree(pageNames, null);
+
+ }
+}
View
25 src/fitnesse/responders/testHistory/TestResultRecord.java
@@ -0,0 +1,25 @@
+package fitnesse.responders.testHistory;
+
+import java.io.File;
+import java.util.Date;
+
+import fitnesse.responders.run.TestSummary;
+
+public class TestResultRecord extends TestSummary{
+ private File file;
+ private Date date;
+
+ TestResultRecord(File file, Date date, int right, int wrong, int ignores, int exceptions) {
+ super(right, wrong, ignores, exceptions);
+ this.file = file;
+ this.date = date;
+ }
+
+ public Date getDate() {
+ return date;
+ }
+
+ public File getFile() {
+ return file;
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.