Skeletest

A quick proof of concept, translating test expectations into code skeleton. The code format is based on practices i read about thanks to Erik Dietrich (the Target idea) and to Phil Haack for wrapping each tested method into a class.

Describe your tests

Handlebar template

Resulting code

What makes it tick?

Inspired by Marcin Stefaniuk and his Concrete-Freetext implementation I used PEG.js to create a javascript parser from a grammar that lets you describe facts for methods in a class. The parser turns your text into a JSON object that is then fed into a Handlebars template that outputs code which is then beautified by syntaxhighlighter

Using it

Start by giving all the namespaces you will be using: using namespace. Then optionally declare the namespace your tests live under: namespace test.namespace. Then declare the SUT with for SUT and the method you are testing check that method_name. Then use a . and type what fact you want to test . returns a fully-build object.

You can chain multiple method tests, and you can declare multiple methods. The parser checks whether a test name contains throws and can let you change the template output to add an expected exception attribute to the test.