http://www.agilenutshell.com/assets/episodes/way-of-web/testing-pyramid.png

Image above is the testing pyramid. But there are many platforms to do UI testing, two of them are:

  • Web (Desktop web, Mobile web)
  • Apps (Android, iOS)
http://images4.fanpop.com/image/photos/18000000/Avatar-Aang-avatar-the-last-airbender-18009331-800-1090.jpg

So if we connected those two to the pyramid, the type could be clarified like this :

  • Web (Desktop web, Mobile web)
  • Apps (Android, iOS)
  • API
  • Unit tests

Just like Avatar, as a Test Engineer, I have to master many types of automation testing. At first, I only mastered about web automation testing. But since the Fire Nation attacked, I have to learn or at least try another type of testing too. Does it make me an Avatar now?

In previous article, I wrote about Golang and automation web use Godog. Now I’ve developed further so that it can be used for other platforms as well. Here are the brief explanations about how to run the test using initial scenario.

First step, please do some installation from this article.

LET’S GET STARTED

https://fiverr-res.cloudinary.com/images/t_main1,q_auto,f_auto/gigs/119898722/original/28217060f0192d123c44c14325b05bfa33fb1917/do-golang-coding-or-scripting-works.png

Driver

  • WEB

For the web version, I use Tebeka for selenium webdriver.

go get github.com/tebeka/selenium

Then it must be imported to the file that needed the driver.

  • APPS

As for apps, I use Agouti for appium driver.

go get github.com/sclevine/agouti

Agouti itself has also contain a driver for web but why I’m using Tebeka and Agouti? Well, the answer is back then I didn’t know how to using Agouti. It’s too hard for me to understand Agouti on the whole. But simply you can see code below as an example how to use Agouti driver.

// Choose a WebDriver:

agoutiDriver = agouti.PhantomJS()
// agoutiDriver = agouti.Selenium()
// agoutiDriver = agouti.ChromeDriver()

Expect(agoutiDriver.Start()).To(Succeed())

Package

You can clone this repo and then run make vendor-prepare or run this command one by one.

go get github.com/DATA-DOG/godog/cmd/godog
go get -t -d github.com/tebeka/selenium
go get github.com/sclevine/agouti
go get github.com/joho/godotenv
go get -u github.com/logrusorgru/aurora
go get -u github.com/magiconair/properties
go get -u golang.org/x/lint/golint

Initial Steps

  • Create folder structures like this.
  • Create main.go and main_suite_test.go in root folder.
  • Create initiate.feature inside scenarios folder.
  • Create initiate.go inside suites folder.
  • Create initiate_steps.go inside stepdefinitions folder
  • Create folder structures like this inside helper folder.
  • Create base.go inside api folder.
  • Create base.go inside android folder.
  • Create base.go inside ios folder.
  • Create global.go inside apps folder.
  • Create base.go inside web folder.
  • Create env.go inside support folder.
  • Create hello.go inside demo folder. This is a function for unit test.

Env and Properties

Since the API scenario need value from env file, so we need to fill in the file.

cp env.sample .env

Feel free to fill in any value in accordance with the variables that have been provided.

For Android and iOS we need to save the capabilities in file .properties and fill in accordance with the type of device you are using.

cp capabilities-android.properties.sample capabilities-android.properties

cp capabilities-ios.properties.sample capabilities-ios.properties

Docker

If you already cloned the golang-automation repo, you can type make and then docker will start (this is for Mac OS, I don’t guarantee for another OS). But if you want to run docker command, you’ll have to copy this.

docker run -d -p 4545:4444 --name selenium-hub selenium/hub
docker run -d --link selenium-hub:hub selenium/node-chrome
docker run -d --link selenium-hub:hub selenium/node-firefox

Running

  • WEB

godog --tags=@initiate-dweb

godog --tags=@initiate-mweb

  • APPS

godog --tags=@initiate-android

godog --tags=@initiate-ios

  • API

godog --tags=@initiate-api

  • UNIT TEST

godog --tags=@initiate-unit

Not all of the examples that I have given here include best practices. For anyone who has never been try unit test and confused what unit test is, maybe we can explain about it like unit test example above.

--

--

Ferawati Hartanti Pratiwi
Inside Bukalapak

QA (Quality Ambassador) | mpermperpisang official Medium account