Writing good tests

What is a test?

A test is a deliberate action or experiment to find out how well something works

Google Dictionary

The take away here is “find out“.

Therefore testing is not “just checking” rather it involves critical and creative thinking. It is finding out more about something and learning from it.

When testing, information in returned. This information could help decide the best course of action. We write good tests so that the information returned will be useful.

What is a good test?

  • A good test is clear of its intent
  • A good test is easy to understand
  • A good test is easy to follow

Ideally, a test should answer the why, what and how.

Also, tests should short. It is recommended to test only one expected result so that it would be more deterministic.

What is a test case

Test cases are conditions in a given scenario.

In other words, it is a story- a beginning, middle and end.

This goes well with Gherkin and Arrange-Act-Assert pattern.

Test cases when done right, become specifications for the product.

How to write a test case

  1. Analyze the given scenario
  2. Think of conditions and expected results as test ideas.
  3. Write a test idea in this format WHEN/IF some condition or action, THEN expected result as a test case title.
  4. Think of the steps to achieve the expected result.

Ideally the test case title should be enough as a test. If it passes “what is a good test” criteria, then it should be approved.

For standardization purposes, TDD/BDD style is used to writing tests cases. This way it is formatted in a way that is easy to code for automation.


Manual test case

Scenario: Payment optionsTest Case Title: When pay at hotel option, user should receive a pay at hotel confirmationTest Steps:
1. Book a room
2. Click pay at hotel option
3. User should receive a pay at hotel confirmation

Automated test case


describe('Payment options', function() {
it('When pay at hotel option, user should receive a pay at hotel confirmation', function () {
Expect("Pay at Hotel Confirmation")===PayAtHotelPage().text();

Robot framework

*** Settings ***
Documentation     A test suite for payment options
...               As a user I should be able to pay with different payment options.
Library           SeleniumLibrary

*** Test Cases ***
When pay at hotel option, user should receive a pay at hotel confirmation
    Book a room
    Click pay at hotel option
    User should receive a pay at hotel confirmation

Test Case Review

Reviews are essential to have good test cases. It is also part of the QA process.

Always ask for 2 peer reviewers and have it approved. Ideally a peer reviewer with technical background and another with business background.

This makes sure that all aspects are covered. More so, they can suggest more test ideas or improve the test cases.

Things to look for during peer review

  • Follows “What is a good test?”
  • Follows the recommended format of “WHEN/IF some condition or action, expected result as a test case title.”
  • Grammar, spelling and typo

Create an automated test with selenium, python, and unittest

Given the test automation requirement is to automate the login process and create a note on the web application http://testapp.galenframework.com/ how would you approach this?

I would approach it by exploring the app first. I would get familiar with the user flow, what elements I could automate, what checks to implement. I would make notes on this.

Then I would write a pseudocode.


  1. Launch the web application
  2. Verify the elements exits
  3. Click login button
  4. Input username and password
  5. Click the login button
  6. Verify the elements exists on page
  7. Close the browser

After this I draft my code until the requirement is satisfied. I would test it several times then have someone review it.

After which I can commit it to the main repository as an approved test case.

Of course, the code could still be improved but that’s for another time.

Here is the code I made –https://github.com/kvabapo/tests/blob/master/python_unittest_selenium.py

Comment and let me know your thoughts.


Love your BASHers! .bashrc vs. .bash_profile


Before anything else, let’s look up what BASH is.



Basically, BASH is a type of shell. A shell is an interpreter of commands in a command line environment. We use BASH and it’s syntax to instruct a computer to do things aka as programming.

For every environment, we have settings to configure. .bashrc and .bash_profile does that for us.

We declare our setting in these files. An example would be the PATH.

The difference between the .bashrc and .bash_profile is that the .bash_profile is used on login environments. By default, when we login to a terminal the .bash_profile will be used.

If the environment or application doesn’t need any login permissions, .bash_rc will be used.


What the f*** is PATH?

When installing applications. The installation guide always says to add this to the PATH. But what the f*** does that mean?

:~user$ echo $PATH

As a beginner this is confusing. You just want to get the thing running without errors.

Let’s dig in.

From StackOverflow:

It is a list of directories in which to search for executable files.

It is when you try to execute a command from your shell (or from within some other program in certain ways), it will search through each of the directories in this list, in order, looking for an executable file of the name you’re provided, and run the first one it finds.

Basically, it is a configuration needed in order for your programs to run.

It can be set on the .bash_profile file for Linux/Unix or the control panel for Windows.

To know more about PATH and .profiles check out these links:




Love at VS Code? My first impression

TLDR; I am starting to fall in LOVE with VS Code

As a tester, I write automated tests. I use an IDE or text editor to do so.

Since I learned how to write tests with Python, I used Pycharm exclusively. I liked using it since it is powerful. It has IntelliSense, themes, command line and much more. I used it both on Windows and Mac. However, in time, I noticed it is becoming sluggish. Unfortunately, I don’t have a fast computer so it adds damage to my patience.
Pycharm Screenshot

I explored other text editors like Atom. I liked how minimalist it is. I just can write and run code on it. What’s good about Atom is it is highly customizable. You can import plugins to suit your workflow. So if you miss the IntelliSense, themes, command line and much more, you can just install it. After a while, I also notice it becoming sluggish on Windows and Mac. Sometimes I experience errors because of the compatibility of the plugins. It is frustrating.

Atom Screenshot

I think both Pycharm and Atom are good development tools but it favors power users with powerful computers because they can maximize its features.

Finally, I tried VS Code and I was impressed by it’s UX. So much that I installed it on both Windows and Mac.

Create Test Cases

I liked how the UI is neatly placed. Elements and partitions are well balanced. Intuitively, I can decipher what’s going on with the UI. From the icons to the views and the tabs.

Performance wise, it is faster than what I am used to. It also has all the power and configuration a coder needs. I can go install-happy on installing plugins!

Basically, it’s what they described- lightweight and powerful.

It is excellent for beginners more so power users.

For some reason, I favor using it on Mac just because it feels more smooth.

I haven’t spend a lot of time on it but my first impression was lovely! VS Code did a good job of taking what worked well and what didn’t from other products and improved on it.

My Mac OS crashed. This is how I fixed it.

Yesterday, I received an update notification for the latest release of MacOS High Sierra. So I clicked the update and restart button.

It was noon and I was not at home but in a coffee shop browsing the web about Travis CI. The internet connection was fairly stable in the coffee shop until I noticed the update progress bar was stuck at 50% for some time. I clicked the cancel button and went home.

I restarted the update at home and it was successful until my computer
restarted. I was prompted that an update failed to install. I clicked continue and my computer booted as normal. I was able to use it.

I check the updates and there was still an update left. I thought this was the one that did not install successfully. So I clicked the update button again. My computer rebooted and I was able to use my it flawlessly.

Until I shut it down…

I opened my computer in the evening and it booted slowly until it crashed. I was prompted with this screen.


I tried rebooting nth times to no avail.

I was frustrated.

I calmed down and pondered on solutions. I created a hypothesis that it might be a bad install because of the experience I had earlier noontime.

The solutions I had were bringing it to the Apple store and have it fixed or find online some suggestions. I went with the latter.

Normally, during crashes, the solution is to reformat or erase everything and do a clean install. This solves most problems but with the sacrifice of loss of files and more effort to fix.

I didn’t want to do that.

The suggestion I found online was to reinstall the OS. For me, I had High Sierra as my OS.

So I restarted my computer and pressed  CMD +R  while it was booting.

This procedure will bring up the disk utility app.

On the disk utility, I opt to install MacOS again. My computer restarted and installed MacOS.


I waited 1-2 hours for it to complete. After that, I was able to log in and use my computer. My files were still intact. All of my worries were gone.



  • Don’t download and install an update when the internet connection is unstable.
  • Don’t rush into solutions. Think as many solutions and try the most practical one.
  • Share the problem and solution.

How to run a headless browser with Selenium Python

One day, I came across the word “headless browser” and it made no sense to me. I initially thought it was a fancy term for new web browser brand.


A headless browser is when a web browser is running without seeing it on the screen. It just runs in the background.

To enable this feature the browser options must be configured. In this case, Chrome and Firefox browsers will be used.

Before proceeding make sure that python, selenium, Chrome and Firefox browsers are installed.

Below is the code snippet on how to run a browser in headless mode.

from selenium import webdriver

'''Using Firefox Browser'''
options = webdriver.FirefoxOptions() # selenium 3.8.0 above
options.add_argument('-headless') # alternatively options.set_headless(headless=True)

driver = webdriver.Firefox(firefox_options=options)

'''Using Chrome Browser'''
options = webdriver.ChromeOptions() # selenium 3.8.0 above

driver = webdriver.Chrome(chrome_options=options)

For more samples, kindly visit my GitHub

Command Line hiccup: Could not “cd” to a directory

What happened here? I could not “cd” into the Python Practice directory. Normally this would work.

Screenshot at Mar 19 15-51-19

I found out that white spaces are not recognized. Python Practice has space in between so the computer did not recognize it.

I have to put an escape character “\” for it to work.

The command now looks like this:

cd Python\ Practice/


Another trick I discovered is using the tab key on the keyboard. When I type “cd Py” then hit the tab key it auto-finds the matching folder.

Cool! Hiccup is gone. I can move on and run my scripts!

How to move a slider element with Selenium Python

Ever wondered how to move the slider from left to right?

Screenshot at Mar 18 15-43-17

Luckily I did some research and tinkering. For this example, the slider found at http://seiyria.com/bootstrap-slider/ will be used.

The most important part here is importing and using the ActionChains library. The ActionChains object will drive the slider by setting an offset value.

move = ActionChains(driver)
move.click_and_hold(slider).move_by_offset(40, 0).release().perform()

Sharing my code here.

from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains

driver = webdriver.Firefox() driver.get("https://www.seiyria.com/bootstrap-slider")
slider = driver.find_element_by_css_selector("div#example-1 div.slider-handle.min-slider-handle.round")

move = ActionChains(driver)
move.click_and_hold(slider).move_by_offset(40, 0).release().perform()

Try it out and let me know! It’s also on my GitHub.