My next few entries are going to document my work on remaking a tool (that was originally written in Ruby) in Go. You are welcome to check out the original tool at https://github.com/CGIFederalInc/SimpliTest. I have named my project “Kosher” because it will execute scripts written in the Gherkin language. The original testing framework for Gherkin is named Cucumber…so you can see the trend here.
At this point, I am just scaffolding out the project. It’s going to be command-line driven. After researching the best command-line parsers available, I’ve chosen to go with Cobra. This is the same tool used by Hugo, a static site generator and one of Golang’s largest projects.
I also found the companion library to Cobra named Viper to be a valuable addition to my toolbox. Viper is a configuration file library that can parse all of the most common formats, including JSON, YAML, TOML, and more.
It’s probably very ambitious of me, but I’d like to expand the original capabilities of SimpliTest to include desktop app testing for Windows applications. By running the application atop Appium, it will have the ability to run both browser drivers and desktop drivers.
Well folks, I’ve finished initial development of Kosher. I wound up using the following tools:
- Aguoti (https://agouti.org/): interface for web drivers (similar to Selenium)
- GoDog (https://github.com/DATA-DOG/godog): Gherkin parser that enables tests scripts to be written in human-readable, BDD-compatible scripts (similar to Cucumber)
- Afero (https://github.com/spf13/afero): a virtual file system that abstracts away differences between operating systems making the application platform-agnostic and easier to test
- Cobra (https://github.com/spf13/cobra): command-line parser that enables powerful, maintainable, and user-friendly CLI control
- Viper (https://github.com/spf13/viper): configuration file parser that simplifies use of JSON-based configuration files
- IZpack (http://izpack.org/): a universal installer builder that allows a single installer to be developed for all platforms (or in kosher’s case, Windows and Linux)
At completion, kosher is a collection of over 50 Gherkin step definitions that enable testers to control web browsers and verify test conditions via Gherkin scripts.
Results can be output in any of the formats supported by GoDog. In addition, I added 2 reports that support deliverables/documentation for professional applications. Both of these use Bootstrap 3. One of the extra reports is an elaborate and attractive layout that includes Chart.JS (https://www.chartjs.org/) pie charts. The other is a simplified layout that accurately exports to PDF or imports to Word.
Modifying the Windows Registry
One of the more interesting problems I had to solve was how to modify the Windows registry. For the web driver to maintain a session with Internet Explorer, two entries must be made in the registry (https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver#required-configuration). Additionally, to add kosher to the Windows path, the path’s registry entry must be modified. So, the question is, how do I modify the registry during the installation process?
My first inclination was to configure the universal installer builder I chose, IZpack (http://izpack.org/), to handle this. Having had experience with Wix (http://wixtoolset.org/), I thought this would be a native feature of IZpack. Unfortunately, I couldn’t find a way to do what I wanted. I did, however, discover that IZpack can be configured to call external executables at different phases of the installation process. In the end, my solution was to write a couple of extra Golang programs to handle modifying the registry for windows and adding PATH entries for both Windows and Linux installs. You can check out the code at https://github.com/cbush06/kosher-env.
Ultimately, the user gets a seamless installation process that works on Windows or Linux and adds the kosher executable to either system’s PATH variable. I’d like to thank the IzPack team for their great Java-based installer and the Golang team for their great support of working with the Windows registry (https://godoc.org/golang.org/x/sys/windows/registry).
Clinton is a full-time Software Developer currently working for CGI Federal, Inc. He spends most his days building Java web applications using tools like Spring MVC, Java Server Faces, and VueJS. In his free time, he likes to dabble in Golang, Hadoop, and other cool technologies. Clinton has been married to his wonderful wife Ashley for 8 years. Together, they have a super-handsome, unbelievably cute (no bias here folks) 5 year old son, Andrew.