Learning About API in Depth

Learning About  API in depth

API in depth

Let us understand and learn about API in depth. An API may describe the ways in which a particular task is performed. For example, in Unix systems, the math.h include file for the C language contains the definition of the mathematical functions available in the C language library for mathematical processing (usually called libm). This file would describe how to use these functions and the expected result. For example, on a Unix system the command man 3 sqrt will present the signature of the function sqrt in the form:

SYNOPSIS

#include <math.h>

double sqrt(double X);

float  sqrtf(float X);

DESCRIPTION

sqrt computes the positive square root of the argument. …

NOTE: using OOP languages like Java and C++, you can override the above function simply as sqrt..:)

RETURNS

On success, the square root is returned. If X is real and positive…

that means that the function returns the square root of a positive floating-point number (single or double precision) as another floating-point number. Hence the API, in this case, can be interpreted as the collection of the included files used by the C language and its human-readable description provided by the man pages.

API Output

An output of API could be

  • Firstly, any type of data.
  • Secondly, status (say Pass or Fail).
  • Lastly, call another API function.

Any Type of Data – Example: There is an API function which should add two integer numbers.

Long add(int a, int b)

The numbers have to be given as input parameters. The output should be a summation of two integer numbers. This output needs to be verified with an expected outcome.

Calling needs to be done such as

add (1234, 5656)

Exceptions have to be handled if the number is exceeding the integer limit.

Status (say Pass or Fail)

Consider the below API function –

  • Lock()
  • Unlock()
  • Delete()

They return any value such as True (in case of success) or false (In case of error) as an output.  A more accurate Test Case would be, can call the functions in any of the scripts and later check for changes either in the database or the Application GUI.

Calling of another API / Event – In this case, we call one of the API function which in turn will call another function. For example – First API function can be used for deleting a specified record in the table and this function, in turn, calls another function to REFRESH the database.

A great career is just a certification away. So, practice and validate your skills to become Certified SoapUI Testing Professional

All about API Concepts
Scope of Software Testing

Get industry recognized certification – Contact us

keyboard_arrow_up