Automated tests == reference documentation

Someone was asking about ujax:redirect in Sling. We have no docs on that yet, but how about some (readable) automated test code?

Using automated tests as reference documentation means that the docs will always be in sync with the code – assuming you’re using continuous integration to run those tests often.

People might object to having to read source code, so maybe creating a filter that presents the code in a nicer way would help?

Literate programming for test cases…the idea sounds worth pursuing.

Advertisement

One Response to Automated tests == reference documentation

  1. With a bunch of static methods added to HttpTestBase, you could have test code that is more compact, and also, more importantly since we’re talking about docs, more readable :-)

    public void testForcedRedirect() throws IOException {
    final String location = testClient.createNode(postUrl,
    params(“ujax:redirect”, “http://forced/”),
    headers(“Referer”, “http://referer”),
    false);
    assertEquals(
    “With forced redirect and Referer, redirect must be forced”,
    “http://forced/”, location);
    }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.