DEV Community

Sebastian Pazmay
Sebastian Pazmay

Posted on • Edited on

4 2

Sample test automation framework written in Golang

There are multiple test automation tools which are already well-developed and highly used. However as a POC and to brush-up my golang skills, I have created a sample test automation framework.

The test suites are written in Golang and they can be used to verify Linux systems configuration.

fmt.Println("## TEST CASES ##")
fmt.Println("1. Verify software OS version")
fmt.Println(testSuites.VerifyOSVersion(expectedVersion))
Enter fullscreen mode Exit fullscreen mode

Each test case calls another function which executes and parses the output.

func VerifyOSVersion(osVersion string) (bool) {
    var resultBool bool
    cmdOut, err := exec.Command("cat","/etc/issue").Output()
    fmt.Printf("OS version: %s", cmdOut)
    if err != nil {
        fmt.Printf("%s", err)
    }
    cmdOutStr := string(cmdOut[:])
    if cmdOutStrContainsOSVer := strings.Contains(cmdOutStr, osVersion) ; cmdOutStrContainsOSVer {
        resultBool = true
    } else { 
        resultBool = false 
    }
    return resultBool
}
Enter fullscreen mode Exit fullscreen mode

Furthermore, I have included a CI using github actions. The entire repository can be found in my github.

Heroku

Built for developers, by developers.

Whether you're building a simple prototype or a business-critical product, Heroku's fully-managed platform gives you the simplest path to delivering apps quickly — using the tools and languages you already love!

Learn More

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay