## DEV Community is a community of 643,323 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

# Coding Katas for Software Testers

Alan Richardson
I develop software and test things. I help people develop software and test things better at EvilTester.com and am the Head of Developer Relations at SecureCodeWarrior.com

What would be suitable Code Katas for people wanting to learn how to code to support their testing?

Code Katas are a pretty popular concept for programming:

I don't do Code Katas. John Somnez writes about why he doesn't do code katas here and here is another take on Code Katas from Micah Martin

## Why I don't do Code Katas

• Time
• I don't really have time to dedicate to code Katas
• Usefulness
• When I'm learning a language I really want the code to be useful, because that is what motivates me to learn more.
• I don't want to keep doing the same thing

But I realised recently that I might well do Code Katas, but I haven't called them that.

## My Code Katas

I have written CounterString implementations in:

I have approached the writing of CounterString differently each time I created a new implementation.

And I have revisited my implementation as I learned more about the programming language.

## An Exercise

If you want to use CounterStrings as a way to practice your programming, and potentially consider it a Code Kata.

Here are my suggestions.

1. write code to generate a String starting with `*`, and then `3*`, etc. to the length of your CounterString, e.g this would create a ten character CounterString like `*3*5*7*9*1`. I describe this as Forward CounterString Generation
2. write code to generate a CounterString that matches how JamesBach describes it where the string ends with * and is of the required length and the number before each * is the position of the * in the string, so a 10 character CounterString would read `*3*5*7*10*`
3. instead of writing out your CounterString to the console, write it to a file
4. instead of writing out your CounterString to the console, write it to the clipboard
5. instead of writing out your CounterString to the clipboard, make it type it into a field
6. find a different implementation approach e.g. if you used recursion change it to do something else, if you didn't use recursion try that, if you were reversing strings try doing it without reversing strings
7. create automated scripts that execute your implementation and compare the output with a different implementation e.g. James Bach's perl clip this might initially be a pre-generated file or responses, but create one that calls PerlClip dynamically
8. for the 'ultimate' challenge, try writing an implementation that generates CounterStrings the way James Bach describes it, but does it dynamically so that you could stream the generation. I describe this as Predictive Forward CounterString Generation

With each of these you will create something useful, that supports you in your work. And you'll learn something.

## Other Suggestions

Other code that I seem to keep writing:

• create a verb/noun text adventure game