What would be suitable Code Katas for people wanting to learn how to code to support their testing?
CounterStrings
- `*3*5*7*9*12*15*`
A CounterString is a string like this `*3*5*7*9*12*15*` where the `*` represent the position in the string of the number immediately proceeding it. This is a 15 character CounterString.
These are useful because if you paste them into a field, and are truncated then it is easy to see what they were truncated to, it is as James Bach describes it, self documenting test data.
https://www.eviltester.com/blog/eviltester/2019-02-27-programming-katas-for-testers/
2. Code Katas are a pre,y popular concept for
programming:
• codewars.com
• codingdojo.org
• leanpub.com/codingdojohandbook
3. What would be suitable Code Katas for people
wan5ng to learn how to code to support their
tes5ng?
CounterStrings seem like a good op3on
• eviltester.com/blog/eviltester/2019-02-27-programming-katas-
for-testers/
4. CounterStrings
• *3*5*7*9*12*15*
A CounterString is a string like this *3*5*7*9*12*15* where the
* represent the posi4on in the string of the number immediately
proceeding it. This is a 15 character CounterString.
These are useful because if you paste them into a field, and are
truncated then it is easy to see what they were truncated to, it is as
James Bach describes it, self documen:ng test data.
5. Learn More About CounterStrings
• CounterString algorithms Explained
• sa6sfice.com/blog/archives/22 for James Bach's original wri6ng
and work on CounterStrings
6. Kata Sugges*on - The Naive Forward
CounterString
write code to generate a String star/ng 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 Genera7on
7. Kata Sugges*ons - The Formal CounterString
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 posi;on of the
* in the string, so a 10 character CounterString would read
*3*5*7*10*
The Reverse CounterString Algorithm is good for this.
8. Kata Sugges*ons - Write it to a file
Instead of wri.ng out your CounterString to the console, write it to
a file
A Predic)ve Forward CounterString works well for this, but start
with a forward or reverse algorithm first.
9. Kata Sugges*ons - Write it to the Clipboard
Instead of wri.ng out your CounterString to the console, write it to
the clipboard
You will have to learn a li/le about how your language interacts
with the clipboard but this is a very useful 8mesaving addi8on to
your tool.
10. Kata Sugges*ons - Write it to the Field
Instead of wri.ng out your CounterString to the clipboard, make it
type it into a field
There are mul*ple ways to implement this e.g. :
• actually typing into the field using OS keyboard events
• simulated keyboard events e.g. JavaScript events
• copying to clipboard and triggering a paste
• amending the field directly to add the data
11. Kata Sugges*ons - A New Implementa*on
Find a different implementa.on 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
Repeat one of your original katas and improve it or experiment with
a different approach - not the algorithm, just the implementa=on.
12. Kata Sugges*ons - Test Against an External
Oracle
Create automated scripts that execute your implementa4on and
compare the output with a different implementa4on
e.g. James Bach's perl clip this might ini3ally be a pre-generated file
or responses, but create one that calls PerlClip dynamically
13. Kata Sugges*ons - Predic*ve Forward
Genera*on
For the 'ul+mate' challenge, try wri+ng an implementa+on that
generates CounterStrings the way James Bach describes them, but
does it dynamically so that you could stream the genera+on. i.e it
does not build the full string and reverse it
I describe this as Predic.ve Forward CounterString Genera.on
Future Katas can involve refactoring and improving your algorithm.
14. Example Implementa,ons of CounterStrings
• VBA (Excel) code
• Java main code, java
• JavaScript predic;ve, reverse
• Perl James Bach PerlClip
15. About Alan Richardson
www.eviltester.com | www.compendiumdev.co.uk
• Contact Alan - eviltester.com/contact
• Linkedin - @eviltester
• Twi:er - @eviltester
• Instagram - @eviltester
• Youtube - EvilTester