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.

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);
    }

%d bloggers like this: