I have written a unit test framework called kak-spec for kakoune scripts and plugins. The framework aims to make the development of robust kakoune scripts an easier and more pleasant experience.
Story of kak-spec
One of the big strengths of kakoune is that it can be configured extensively by writing *.kak scripts and plugins. Unfortunately, developing and learning to develop such scripts can be laborious, as some in this forum may have experienced. Personally, I have developed many kakoune scripts in an often painful ad-hoc manner. This is particularly the case when it comes to testing. I have been the sole alpha and beta tester of my scripts, and most of that testing has consisted simply of manual use of my scripts.
Needless to say, such ad-hoc development with manual testing has lead to errors. For example, I have had cases where I write a script that works, but much later I realize that it fails when used with multiple selections, or with a selection containing only a single character, or in an empty buffer, or on the first or last character of the buffer, or after a kakoune update has changed some behavior. Most of these problems would have been avoided by proper testing.
Given these experiences, I looked for existing testing practices for kakoune scripts and found that the kakoune repository itself has a regression test script that can be adapted for plugins as well. That is great! I proceeded to copy it and use it for some personal plugins that I have. This was a nice improvement–I was finally unit testing some of my scripts. I should have done so from day one!
Despite having now unit tests, my experience was not quite as smooth as I had come to expect from using frameworks for other languags like rspec for ruby and crystal spec for crystal. I admit the comparison is not quite fair though, since one is a testing script for a single project whereas the others are entire unit testing frameworks aimed at large user bases of entire languages. Nevertheless, I grew to want changes to the facts that the kakoune regression test script
- requires each single test to be specified as a directory of multiple files,
- takes its time to run each test using a dedicated kakoune process, and
- is not available as a conveniently installable script that you can easily run on any plugin.
Motivated by the above, I developed the unit testing framework kak-spec that
- conveniently allows writing multiple test cases in a single file,
- saves time by starting one kakoune process per test file rather than test case, and
- is available as an installable executable that can be ran easily on any spec file you choose.
For more information, please see the repository kak-spec. I hope that kak-spec can be of use to many developers in the kakoune community. Please let me know if you have suggestions/thoughts/issues.