ExcelConcordionTutorial.xlsx

Introduction

The Concordion Excel parser contains functionality for converting tests written in Excel format (like this one) into HTML format for Concordion to process.

There are two great reasons why you would want to use Excel as the native format for your tests:

1. You want to include calculations in the test, to demonstrate how an expected result is calculated.

Let's say you were writing a formula, and you wanted to write an acceptance test for it. You might start by including some examples like so:

A BCResult
52111.0
92119.0
55126.0
52212.0

Rather than sitting down with a piece of paper and working out all the values in the "Result" column, you might be able to save time by writing an Excel formula for doing it

Not only might this be easier to do and less error-prone than the pencil-and-paper way, but it serves as a demonstration to the developers of how the formula should work.

2. You want to take advantage of Excel's superior UI for manipulating tabular data

Creating tables of data in HTML format for Concordion can be a bit of a faff.

However, the Excel GUI as it stands is very good at tables. If you have people on your team without HTML skills (say, business analysts) they may find putting tests together in Excel a bit easier than in HTML.

Paragraph Layout

When unformatted rows of a spreadsheet are sent to the ConcordionExcel extension, individual rows are turned into HTML paragraph tags like this:

A simple HTML Paragraph

Background colours are respected

Cells on the same row are placed on a single line.

Table Layout

By turning a piece of your Excel sheet into a table, you can make it a Concordion table too:

First NameLast NameAge
JenniferAniston42
JeffBridges66
JohnWayne78

To turn an Excel range into a table, select the table (including the title row) and choose Insert->Table from the menu.

Adding Commands

When using Concordion's HTML format, instructions to concordion are embedded as attributes in the HTML, like this:

<div concordion:assertEquals="blah()">blah</div>

All commands in the "concordion:" are supported by the Excel Parser.

You can add commands by adding them as cell comments in the Excel spreadsheet. E.g

blah This goes green because I added a comment containing concordion:assertEquals="blah()" to the cell, and I have this method on the test:

public String blah() {
  return "blah";
}

To add a cell comment, right-click the cell and select "Insert Comment"

Wrapping HTML

The text contained in the cells of your Excel test will be escaped when it is put in the document.

However, you can tell the Excel Parser to use a different tag for a cell, like this:

Some Text

The above text is wrapped in a <center> tag. To do this, a comment is added to the cell with:

html-tag="center"

The "pre" tag is also a useful tag to wrap with (used in this tutorial to show HTML and Java code snippets).

html-tag="pre"

An example of text wrapped in <pre>.

Adding Commands To Tables

Concordion allows us to build tests using tables, like this (taken from the Concordion tutorial):

Full NameFirst NameLast Name
John SmithJohnSmith
David PetersonDavidPeterson

To do this, we set up the table with concordion attributes in it like this:

<table concordion:execute="#result = split(#fullName)">
  <tbody>
    <tr>
      <th concordion:set="#fullName">Full Name</th>
      <th concordion:assertequals="#result.firstName">First Name</th>
      <th concordion:assertequals="#result.lastName">Last Name</th>
    </tr>
  </tbody>
</table>

etc.

Because HTML is a hierarchical structure, it's possible for a test designer to place concordion commands at any level of the HTML structure

However, an Excel spreadsheet is a two-dimensional grid, and so doesn't support the same kind of hierarchy.

We can get round this by prefixing the attributes when we add them to to Excel cell comments. E.g.:

(table)concordion:execute="#result = split(#fullName)"

This instructs the Excel Concordion Parser not to add the attribute to the current element, but the nearest ancestor table element

Namespace Support

If you are defining your own concordion extension commands, you will need to give these a namespace.

In HTML, you might set this on the opening tag of your test:

<html xmlns:concordion="http://www.concordion.org/2007/concordion"
   xmlns:mynamespace="http://com.example.namespace">

The Excel Concordion extension automatically sets up the concordion namespace.

The other namespace we have to set up ourselves in the spreadsheet.

Recall that you can prefix a concordion attribute with the name of the element it needs to go on. So for example, you can add a comment to a cell on the workbook containing:

(html)xmlns:mynamespace="http://com.example.namespace"

Having done this, Concordion will work it's way up the HTML tag structure until it gets to the top-level <html> tag, and add the namespace instruction there.