Category: QA

API Testing

Hi friends, today we are going to discuss API Testing. While testing, lots of time we came across the words request, response, output etc. These words have predefined meaning. We will go step by step to know about API Testing.

What is API?

API is “Application Programming Interface”. API mainly used for data communication between two modules or systems. A source sends a request to destination and destination sends a response to the source using API.

API

Types of API’s :

REST and SOAP are the types of API’s. Most of the times developer choose to go with REST API structure style. REST is lighter than SOAP.

REST :

REST is “Representational State Transfer”. REST is an architecture style while SOAP is a protocol. REST based web services use URI. URI is “ Uniform Resource Identifiers. REST web services are in resource structure architecture. The resource would be a chunk of respective information e.g. User id, profile etc.

Rest uses simple HTTP calls to access resources. The application sends a request to another system/backend/module and the destination will send a response to the application.

How RESTful service works?

RESTful services use HTTP verbs to determine the which operation to be performed.

GET method: To get an information
PUT method: To update an information
POST method: To create an information
DELETE: To delete an information

Let’s take an example of how REST API works.

There are lots of tools available like Postman, Poster etc to verify request and response. Here I am using Charles tool. Using this tool user can send a request and test the desired output is coming or not. Also, a user can edit the request with test data as an input and test the desired output with respect to given input.

To use Charles you need to put “Request URL” in the browser tab (Request URL can be taken from -> Inspect header element by hitting the desired URL). Refer below screenshot.

screenshot

Charles Session for the Desired request:

Charles session screenshot

If you want to edit the request you need to right click on the request and provide desired input and click on execute. After execution check for desired output.

SOAP:
SOAP is “Simple Object Access Protocol”. SOAP is the XML based protocol used for connecting the application with the backend. SOAP API is language independent platform. It must be parsed before use as it uses XML formatting.

For SOAP, the testing user must give a file in WSDL format. WSDL is: “Web Services Description Language”. The user can use SOAPUI tool for testing SOAP API.

Prerequisites:

SOAPUI Link: https://www.soapui.org/downloads/soapui.html
WSDL file for API: Sample WSDL file for test / to get start off: https://www.soapui.org/getting-started/your-first-soapui-project.html

Let’s take an e.g. In SOAPUI, we need to add desired WSDL file which we want to test.
Steps:
Install SOAPUI tool
Click on ADD new Project
Right-click on the project and then Add desired WSDL file and click on ok.

After adding necessary prerequisites, click on SOAP and provide desired input XML for appropriate output.

Reference: https://www.soapui.org/soapui-projects/soapui-projects.html

soap UI

Hope this information helps you. Wishing you a very happy API Testing.

Author: Omkaar Deshpande
Email : omkaar@idyllic-software.com
Linkedin: https://in.linkedin.com/in/omkaar-deshpande-63a9001a

Cyclomatic Complexity

Hi all, you may have come across a concept called Cyclomatic complexity while preparing for ISTQB. You may also have read it as a concept under the White box Testing, it’s because we actually need to refer the code of the feature/application for calculating Cyclomatic complexity.

Why Cyclomatic complexity:

1.Cyclomatic Complexity is a kind of structural measure.

2.What is a Structural measure: It means a measurement used to calculate the complexity and vastness of the code, effects of changes made in the code and testing efforts (including reviews)required, also to decide the technique and tool to be used for testing.

What is Cyclomatic complexity:

1.     Cyclomatic complexity is a number which tells us about the complexity of the code/feature.

2.    There are many ways to calculate CC (Cyclomatic Complexity). Some basic of them are as follows

a.    V(g)= E-N+2

V(g)= cyclomatic complexity factor

E= # of edges

N= # of nodes

2= these are termination points(i.e., START point and END point)

b.    V(g)= L+2

Where,

L = # of Loops in the flow diagram

*Loop: It executes a statement based on a given condition. Example: if-else, while,  for etc.

3.    So on calculating CC factor we will get a number, this number will further tell us more about the complexity, cost and efforts required for that feature.

4.    The number is then categorized to find the complexity and other parameters in the following way:

a.   If the number, n<10

Then the project is structured and low complex, since low complex, the testability is high. Also, the efforts required will be less, so the costing also will be less.

Example:
Login page,

{ 
#enter valid username/email id
#enter valid password
#hit login
//if any of the above parameter is invalid-throw an error message
}

In this example system will only check for the valid and invalid parameters and will either permit the user (for valid cases) or display an error message (for invalid cases). Hence, Login page is highly testable as it has limited combinations of input & output. Efforts required are very less and the cost is also less.

b.  If number, 10<n<20

Then the project will have medium complexity hence the testability will also be medium. Efforts required will increase in this case also the cost of the project.

Example: Google Maps: If I try to search for Gateway of India-Mumbai in Gmaps then,

A.   System will first execute the country Loop and will give the output as Asian countries

B.    In Asian countries will search for India

C.    In India will then search for Maharashtra

D.   In Maharashtra will search for Mumbai

E.    In Mumbai will search for Gateway of India

F.    Now will pick my current location

G.    And will calculate and display the distance from my current location to Chinchwad

H.   Also will display the time required to reach there based on the mode of traveling chosen

These will be the loops while using the Gmap hence the code is a bit complex, also, a small change in any of the above loops will have cascading effects, hence the testing efforts also increased. Thus, the costing increases.

c.  If number, 20<n<40

Then the project complexity increases on a higher level by reducing the testability to a lower level. Efforts required and costing of such projects is high.

Example:Banking domain website

 With features like: transactions, payments, shopping points, loan related info, mobile banking, traveling, ticket booking, dining and home delivery of meals, Insurance buying, various investment options etc.

In this case, the efforts required will be more since there are many factors to be considered. Also, security and privacy will be a higher priority. Such projects involve a lot of mathematical calculations with minimum precision deviation. The cost of such projects is too high as security and privacy are targeted and consists of financial transactions.

d.  If number, 40<n

Then the project complexity is immense, hence, the possibilities of end to end testing are less. The efforts required and costing is also too high.

Example:For this case we can consider e-commerce an example. In e-commerce there are continuous release cycles, hence, an end to end testing for each release is less possible. Thus, this increases risk, efforts and costing of the project.

How to use Cyclomatic complexity?

Control flow diagram is always used for calculating the Cyclomatic complexity of any software. We will now go through a short example where we will be using the above concepts of cyclomatic complexity.

Example of CC:

We will take following simple example as client’s requirement :

Calling from one mobile phone to another. Client’s requirement are as follows:

1.     Country code of the dialed number to be displayed

2.    If any ISD number is dialed then display the country name

3.    Also check and display Service provider name and update in DB

4.    If a STD number is dialed apply roaming charges

5.    Call charges will be based on the type of service opted i.e. prepaid or postpaid

6.    If the call is made in night hours, apply night calling charges

7.    Call charges will depend upon the corporate or noncorporate service opted

8.    If the number is bound to any special plans, apply call charges as per the special plans

9.    If the call is answered, then check the answering mode i.e.answered by the user or answering machine.

10.  If the call is answered by an answering machine, then record a voice message after a beep and disconnect the call when the user disconnects.

11.  If the user disconnects the call. End the call.

Please refer below image for a flow chart of above-mentioned example.

Flow chart

 

By using the first formula of CC:

V(g)= E-N+2

= 37- 27+2

= 12

Now we’ll calculate the CC by using the second formula for the same flow chart:

V(g)= L+2

= 9+2

= 11

Since the CC factor obtained is 12 by using formula 1 and by using the second formula we get the CC factor as 11 since both of them fall in the 2nd category, the code is medium complex, required testing efforts are also medium, thus resulting in a medium costing project.

I hope you found my blog to be helpful.

Author: Sonali Sorate
Email : sonali@idyllic-software.com
Linkedin: https://in.linkedin.com/in/sonal-sorte-06757217

Test Cases Made Easy

In the beginning of my career, I used to write test scenarios/cases in behavior driven development (BDD) style, which was a not a globally accepted test cases writing  practice. I then discovered that this was a style of writing used in automation acceptance testing supported by Cucumber tool. Cucumber is a tool which facilitates BDD style more prevalent in Ruby ecosystem.

Example : Login scenario

BDD style_test case

The more I researched on how to write test cases I have learned the below things which I am sharing with you all.

What is a use case and its relation to test case?

The use case and the test case are related to each other in the following way:

– Use case is a document prepared by Business Analyst on the requirement specifications, which is in a more elaborate pictorial format. Test cases are derived from these use cases. They also contain real time scenarios.

– Test cases is a document prepared by Test engineers or Quality Analyst based on the Use cases provided by BA. It is in step-by-step descriptive format of functionality with scenarios, steps, defined inputs, expected result, actual result and remark(Pass/Fail)

What are Test cases?

Test cases are a set of conditions, on whose successful execution proves that the system is working as per customer/business requirement. Test case need not be written after getting the first built instead they can also be written after preparing the System requirement specifications or after obtaining the ticket of a business requirement for any feature. Test case are maintained in version format if any changes are made to the original feature.

Why write test cases?

We should carry forward the practice of writing test cases for below reasons:

  • – cover all corner cases
  • – end-to-end test coverage
  • – to maintain the version of changes in the original feature

What are the types of test cases?

Test Cases can be written based on the type of testing: Functional, Nonfunctional, and Automation. There are majorly two types of test cases:

Test cases for manual testing:

For manual testing we have functional and non-functional test cases:

Functional test cases are test cases written for actual functionality, end-to-end application flow and look & feel of the system/application. Non-Functional test cases include Load testing, stress testing, installation and uninstallation of the system/application.

Test cases for automation testing:

In automation, even though we consider the end to end flow, we do not execute each and every test case. We on high priority cover major, critical, important modules, and repetitive work in automation process hence some part of test cases (depending upon the application) from manual test cases are fetched and executed.

How to write Test Cases in an appropriate way?

Template of writing test cases differs from organization to organization. In some organizations test cases are written in excel sheets or Google spreadsheets are shared across, while in some organizations HP-QC tool is used for writing test cases.

Basic attributes of writing test cases are:

      1. 1. Project name:
          • • SRS version
          • • Requirement ID
          • • Test ID
          • • Test  cases written by
      2. 2. Testing Scope:
          • • Test steps
          • • Expected result
          • • Actual Result
          • • Conclusion
      3. 3. Review:
          • • Reviewed by
          • • Reviewed on Date
          • • Reviewed Comment

One of the easy and acceptable way for writing test cases can be:

test case_format

What is a Traceability matrix?

Traceability matrix: It is a tabular format which maps the functionality and test cases for a system/application. The main objective of traceability matrix is to cover maximum test cases and no functionality is missed while testing. And it is one of the best practice of testing.

Author: Sonali Sorate
Email : sonali@idyllic-software.com
Linkedin: https://in.linkedin.com/in/sonal-sorte-06757217

 

Appium: Mobile App Automation Made Awesome

Mobile Automation

Welcome to the world of Mobile App/Website automation testing. Here we are going to learn how to set up/configure a system to automate application or website on mobile. Also, we will see a sample code to run mobile automation script using Appium tool.

Why Appium?

Appium is an open source mobile automation tool which allows the user to write effective functional scripts. The biggest advantage of Appium tool is QA can write automation script in any language e.g. Java, Ruby, Python etc.

Prerequisite:

iOS :

Native Android:

 

Sample code to execute mobile automation script:

Step 1: Set desired Capabilities

DesiredCapabilities

Step 2: Run code with appropriate changes

CodeSnippet

Selenium:Running parallel tests on different browser

Run parallel test execution in 3 easy steps:

• Setting up Selenium Grid Server
• Adding node to hub
• Sample Code using TestNG

Setting up Selenium Grid Server

  1. – Download Selenium server (.jar) from : Selenium Standalone Jar
  2. – Place the .jar file at preferred location
  3. – Open command prompt and go to the location where .jar file is placed
  4. – Run command : java -jar selenium-server-standalone-2.52.0.jar -role hub
  5. – Verify whether hub is running using URL :  http://localhost:4444/grid/console

Adding node to hub

  1. –  Open a new command prompt instance (as hub is already running on previous instance) and go to the location where .jar is placed
    Run following command :
    java -jar selenium-server-standalone-2.52.0.jar -role webdriver -hubhttp://172.16.15.140:4444/grid/register -port 5568
    (Note that the IP address provided should be of the client machine. If you are running scripts on same machine then use same IP address of the server machine.)
  1. – Above command will add a single node to the hub.
  1. –  To add multiple nodes open and run same command in new command prompt. Make sure that the port will be different for each node.
    eg.
    1. java -jar selenium-server-standalone-2.52.0.jar -role webdriver -hubhttp://172.16.15.140:4444/grid/register -port 5568
    2.  java -jar selenium-server-standalone-2.52.0.jar -role webdriver -hubhttp://172.16.15.140:4444/grid/register -port 5569
    Above node will work successfully for Firefox
  1. – If you are trying to add a node to hub for Internet Explorer (IE) use
    following command :
    java -jar selenium-server-standalone-2.52.0.jar -role webdriver -hubhttp://172.16.15.140:4444/grid/register -port 5555 -Dwebdriver.ie.driver=”C:/Selenium/Grid/Resource/IEDriverServer.exe”
  1. – Verify whether hub and nodes are running using following URL :
    http://localhost:4444/grid/console

 

Sample Java and XML code

JavaCode   XMLFile

Subscribe To Our Blog

Get access to proven marketing ideas, latest trends and best practices.

Next up home

Contact

Lets build cool stuff

Share your contact information & we will get in touch!

I want (Tell us more about your dream project)