A Simon 4 case study: the default "Dejal posts" test

When I released the major version 4 upgrade of Dejal Simon, I included a couple of new default tests as examples for new customers. One of them is named "Dejal posts", and actually includes a quite sophisticated set of filters.

The general idea of this test is to look at the Recent Posts page of the Dejal site, which lists all recent blog, forum, FAQ etc posts and their comments, and output some tidy text describing the most recent one, along with a changed state when a new post or comment is added.

I thought it'd be interesting to break down this test as an example and tutorial for new and existing customers — even long-term users might learn something!

Firstly, here's the Service page; nothing remarkable here (the cookies are automatically recorded, and unimportant for this test):

[Service page]

The most interesting page is the Filters one (click to see it full-size; you might want to use the appropriate modifier key for your browser to open in a new window):

[Filters page]

When you check the test and look in the Activity log, you can see the output from each of those filters (from bottom to top) — click to see full-size:

[Activity log]

Another way to view the output is via the Preview pane, which now includes not only the service response and headers, but also the full output of each filter, to help you diagnose each step.

Here's the output of the service; the full HTML of the web page:

[Preview service response]

Let's break down each of the filters, via the Preview filter output.

The first filter, a Block one, takes the service response as its Input, and has Start text of <tbody> and End text of <td class="replies">. This finds the first occurrence of each of those bits of HTML in the service response, which corresponds with the most recent post information:

[Filter configuration]

This filter outputs that:

[Preview filter output]

The second filter is another Block one. It takes the output of the first filter as its input, and narrows it down further to just the title of the post. Notice that it also uses options disclosed on the right-hand-side of the filter configuration: it looks for the second occurrence of the Start text, searching from the beginning of the input:

[Filter configuration]

The output of this filter is the post title:

[Preview filter output]

The third filter is yet another Block (it is one of the most useful filters), but the input is different: this time it uses the output of the first filter, instead of the previous one (as is the default). It also has an option to look for the third occurrence:

[Filter configuration]

It extracts the author information:

[Preview filter output]

Filter number four is different. It uses a Ignore Links filter to extract out just the author name from the previous filter output. The previous filter doesn't do this as when you're not logged in on the Dejal site, only the name is included (in which case this filter has no effect):

[Filter configuration]

The output is just the non-HTML part of the input:

[Preview filter output]

Next we're back to a Block filter again, but this time looking at the original service response text to extract the number of replies to the post:

[Filter configuration]

This should always output a number:

[Preview filter output]

We then use a new filter introduced in version 4, Singular or Plural, to take the number found in the previous filter and output "reply" if it is one, or "replies" for any other number:

[Filter configuration]

As seen in the preview:

[Preview filter output]

The last filter puts it all together: an Override Custom filter uses variables to combine the output of several filters in a nice readable way. In this case all the variables are variations of the filter output, but other variables are available too. Something that isn't immediately obvious is that you can insert numbers to reference specific filters (otherwise it refers to the previous one):

[Filter configuration]

Which results in:

[Preview filter output]

So now that we've got some nice output text, what do we do with it? Of course, you can just see it in the Tests list, if you have the last change and failure displayed:

[Tests list]

But you'll probably want to get a notification. For myself, in addition to some generic speech notifiers, I have a notifier to post to the @SimonBot Twitter account; an account I added just for Simon to tweet about Dejal site changes:

[Notifiers page]

The SimonBot notifier also uses variables to add more information about the test:

[SimonBot notifier]

Which appears like this:

You're welcome to follow @SimonBot to learn about Dejal news and discussions.

I hope this case study is helpful. Most tests don't need a series of filters like this, and there are other ways to achieve similar effects (like writing all the logic in a script), but it can be very useful when you want it. You can use similar techniques in your own tests.

I plan to do more case studies or tips on Simon features in the future; please leave a comment if you like this or find it useful, or have suggestions for other things you'd like me to cover.