Integrating Tessl into Test-Driven Development workflows
In this tutorial you'll start with a spec with tests first and then build code.
By default, the Tessl framework favours fast cycles of spec change - code generation - manual testing. This approach allows you to focus on rapid development of new or updated capabilities first and foremost. Once you are happy that your core functionality has been captured, you can fine-tune the application with a more rigorous set of tests. This does require more time, however, as it demands a greater investment in test and fix cycles. For more information about how to do this, read our Adding tests to specs common workflow.
Test-Driven Development (TDD), however, is an approach whereby the tests are built first and fail until the required development code has been written to make those tests pass. In spec-driven development, this is done by creating your spec with your tests upfront and then testing the implementation against the tests at every stage of the build.
Let’s look at an example and share how we could change our request to the agent and CLI.
First, I’ll create a spec that sums basic dice notation. For example, 2d6 would be the sum of two rolls of a six-sided dice. This could be anything from 2 to 12.

This process took me through the bootstrapping process and created the following spec:
Notice the capabilities don’t have any tests associated with them. I need to perform three tasks from here:
Add tests to the spec file
Generate the test files
Generate the code
I’ll ask my agent to edit the spec first to add tests, then generate the code files from the spec, and finally generate the code. From this point on, the `tessl build` command will always run my tests as part of the process.

After the spec has been edited, my capabilities in the spec have been updated as follows:
The next step is for Tessl to generate the tests, which it does via the build-tests tool. This generates the dice-notation.test.js
test file mentioned in the spec.

Finally, the code is built and the tests are successfully run:

Subsequent Tessl builds will run the tests if you pass a test command, such as testCommand: "npm test"
and this will then adhere to the test-drive development workflows going forward.
Last updated