Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added comment columns for Query tables

  • Loading branch information...
commit 9f23a53ae23320f2942ba846a09c41d8df4382dd 1 parent 3511b0c
@mbarchfe mbarchfe authored
View
15 src/fitnesse/testsystems/slim/tables/QueryTable.java
@@ -14,10 +14,10 @@
import fitnesse.testsystems.slim.Table;
import fitnesse.testsystems.slim.results.SlimExceptionResult;
import fitnesse.testsystems.slim.results.SlimTestResult;
-
import static util.ListUtility.list;
public class QueryTable extends SlimTable {
+ private static final String COMMENT_COLUMN_MARKER = "#";
protected List<String> fieldNames = new ArrayList<String>();
private String queryId;
@@ -165,7 +165,10 @@ protected TestResult markField(int tableRow, int matchedRow, int col, QueryResul
String actualValue = queryResults.getCell(fieldName, matchedRow);
String expectedValue = table.getCellContents(col, tableRow);
SlimTestResult testResult;
- if (actualValue == null)
+ if (fieldName.startsWith(COMMENT_COLUMN_MARKER)) {
+ testResult = SlimTestResult.plain();
+ }
+ else if (actualValue == null)
testResult = SlimTestResult.fail(String.format("field %s not present", fieldName), expectedValue);
else if (expectedValue == null || expectedValue.length() == 0)
testResult = SlimTestResult.ignore(actualValue);
@@ -259,9 +262,11 @@ public int findBestMatch(int tableRow) {
private void eliminateRowsThatDontMatchField() {
String fieldName = fieldNames.get(fieldIndex);
- Iterator<Integer> rowIterator = matchCandidates.iterator();
- while (rowIterator.hasNext())
- eliminateUnmatchingRow(rowIterator, fieldName);
+ if (!fieldName.startsWith(COMMENT_COLUMN_MARKER)) {
+ Iterator<Integer> rowIterator = matchCandidates.iterator();
+ while (rowIterator.hasNext())
+ eliminateUnmatchingRow(rowIterator, fieldName);
+ }
}
private void eliminateUnmatchingRow(Iterator<Integer> rowIterator, String fieldName) {
View
27 test/fitnesse/testsystems/slim/tables/QueryTableTestBase.java
@@ -283,6 +283,33 @@ public void variablesAreReplacedInMatch() throws Exception {
}
@Test
+ public void commentColumn() throws Exception {
+ queryTableHeader =
+ "|" + tableType() + ":fixture|argument|\n" +
+ "|#comment1|n|#comment2|\n";
+
+
+ assertQueryResults(
+ "|first|1|comment|\n"+
+ "|second|2||\n" ,
+ ListUtility.<Object>list(
+ // trying to ensure that the comment field does not participate in
+ // row matching
+ // if comments were not ignored, the best match would be set from the comment fields
+ list(list("#comment1", "second"), list("n", "1"), list("#comment2", "")),
+ list(list("#comment1", "first"), list("n", "2"), list("#comment2", "comment"))
+ ),
+ "[" +
+ headRow +
+ "[#comment1, n, #comment2], " +
+ "[first, pass(1), comment], " +
+ "[second, pass(2), ]" +
+ "]"
+ );
+
+ }
+
+ @Test
public void variablesAreReplacedInExpected() throws Exception {
makeQueryTableAndBuildInstructions(queryTableHeader + "|2|$V|\n");
qt.setSymbol("V", "5");
Please sign in to comment.
Something went wrong with that request. Please try again.