Posts Tagged ‘Quality assurance’

What do we use for Testing Rest APIs, Advanced Rest Client, Jmeter? Sometimes it becomes so boring to do things in conventional way. Let’s try something different and walk away from the Mainstream Testers.

This post is all about breaking your limits and do some real coding. So let’s get started.

So what is CURL? It’s a command-line tool for transferring data using various protocols.Basically you can hit any URL and get it’s response.

Similarly we can execute an API and check for the HTTP response to find out whether the API is working as expected or not.

You need a Linux Machine to use CURL otherwise you can download in for your Windows and Mac OS from here: http://curl.haxx.se/download.html

CURL SCRIPT:

curl –write-out “%{http_code}\n” –silent –output /dev/null “http://www.igyaan.in

The above code will print HTTP Status code in the terminal

Description of the option used (–write-out)

write-out – write-out is extremely useful. This option allows you to specify extra information that you want curl to print, using special variables. For example, to print the HTTP response code of your request, you use the “http_code” variable. You must enclose the variables in %{}.

silent – It allows one to suppress the progress output that curl prints when the command is run

output – It writes HTTP Status code in /dev/null file temporarily

What is Bash Script? Bash is a command processor, typically run in a text window, allowing the user to type commands which cause actions. Like all Unix shells, it supports filename wildcarding, piping, here documents, command substitution, variables and control structures for condition-testing and iteration.

And yes, you need a Linux Machine.

I will use the same CURL command from above and will create the bash script. Have a look at the simplest if else program to check the HTTP Status Code.

BASH SCRIPT:

#!/bin/bash

STATUS=$(curl –write-out “%{http_code}\n” –silent –output /dev/null “http://www.igyaan.in “)

if [[ STATUS -eq 200 ]]; then
echo “Success”
else
echo “Failed”
fi

Save the file with a file name ending with .sh e.g. TestAPI.sh

Finally run this script with the following command:

bash TestAPI.sh

It’s a very simple program so I am not going to explain this. But please post comments for any queries

Hope you liked it and will eager to explore CURL and BASH scripts 🙂

Advertisements

Mobile Automation Testing is a must for every project nowadays. I am not going to talk about advantages and disadvantages of Automation Testing here. I want to discuss about few basic but important things that can help write effective Automation Code for any platform.

When we start our Automation Project, we all involve ourselves into various strategies and techniques to test a functionality End to End. We implement Test Execution steps, Data Driven Framework (mostly), Reports, Loggers and what not. To navigate through various screen having data or images, we write predefined wait conditions or we implement complete codes to wait by ourselves. Even though we face few issues like timeout/specified element/screen not found error and etc while waiting for an activity (in android) / screen / UI elements. So, we happen to run and test our code multiple times to ensure that our code works fine and it’s the device or app which is having problem. Finally we let it go and publish our code.

But we always forget or ignore basic OS function/Apps in Device. Here are few tips which will can fix these issues.

  1. Disable Animation in your Device: In Android, Go to Settings > Developers options and set “Window animation scale”, “Transition animation scale”, “Animator duration scale” to “Off”. In iOS, Go to Settings > General > Accessibility and turn off “Reduce Motion”
  2. Force Stop / Uninstall any app which uses internet
  3. Turn off Automatic Sync for your mails / Dropbox or any other apps/widgets
  4. Close all background apps
  5. Clear your RAM and have adequate memory available
  6. Select a good Wifi Connection or use Mobile Network. 4G or 3G is preferable than 2G
  7. Use an Automation Tool which gives maximum accuracy level. E.g. Robotium for Android (You should also checkout Google’s “Espresso – Android Test Kit”)

Hope this will help you next time when you perform Automation Testing. Please do comment on the post and share your thoughts.