Cross_Column

Sunday, 11 April 2021

Contract Testing Overview

Contract Testing in API







Microservices :-

Microservices is an architectural design for building a distributed application using containers. Microservices get their name because each function of the application operates as an independent service. This architecture allows for each service to scale or update without disrupting other services in the application.



Contract Testing :- Contract testing is a way to ensure that services (such as an API provider and a client) can communicate with each other. Without contract testing, the only way to know that services can communicate is by using expensive and brittle integration tests.

A service consumer and a service provider interact with each other based on some protocol or rules. This set of rules of communication between two services is called Contract and the process of testing the communication between the two services based on this Contract is called Contract Testing.




Wednesday, 31 March 2021

API Testing Interview Questions

API Testing Interview Questions







What are Web Services?

A web Service can be defined by the following ways :-

1). Is a client server application or application component for communication.
2). Method of communication between two devices over network.
3). Is a software system for interoperable machine to machine communication.
4). Is a collection of standards or protocols for exchanging information between two devices of application.

What all challenges are included under API Testing?

API Documentation
Access to DB
Authorizarion Overhead

What is the difference between PUT and POST methods ?

Post :- Creating a new object on the server
Put :- Update the object in server with new table

What are Commonly used HTTP methods?


GET :- It enables you to retrieve data from a server
POST :- It enables you to add data to an existing file or resource in a server
PUT :- It lets you replace an existing file or resource in a server
Delete :- It lets you delete data from a server

List out few Authentication Technique used in API's?


Session/Cookie based Authentication
Basic Authentication
Digest Authentication
OAuth

What is Rest API?


REST stands for Representational State Transfer. It is set of functions helping developers in performing requests and receive responses. Interaction is made through HTTP protocol in REST API.

What exactly needs to verify in API testing?

In API testing, we send a request to API with the known data and then analysis the response.
1). We will verify the accuracy of the data.
2). Will see the HTTP status code.
3). We will see the response time.
4). Error codes in case API returns any errors.
5). Authorization would be check.
6). Non functional testing such as performance testing, security testing.

What are path parameters and Query parameters for below API Request URL

/ for path parameter
? is for Query parameter
for example http://way2testing.com/tutorialorder/1122369?location=GHN

so here /1122369 is path parameter
and ? location is Query parameter also in In General Query Parameter is constructed at the end of URL.

Whar are the core componenets of a HTTP request?

HTTP Request methods like PUT, POST, Delete.
Base Uniform Resource identifier (URI)
Resources and Parameters
Request Header, which carries metadata(a key-value pairs) for the HTTP Request message.
Request Body, which indicates the message content or resource representation.

What could be the HTTP method for below API Scenario? Answer if it is GET or POST.

Scenario :- An API which has Endpoint, Parameter, Headers, cookies and Payload.
Answer :- It is a POST request because it have Payload

What are the differences between API Testing and UI testing?

UI(User Interface) testing means the testing of the graphical user interface. The focus of UI testing is on the look and feel of the application. In user interface testing the main focus is on how user can interact with app elements such as images, fonts, layout etc. are checked.
API testing allows the communication between two software systems. API testing works on backend also known as backend testing.

What protocols is used by the RESTFUL web services?

RESTFUL web services uses the HTTP protocol. They use the HTTP Protocol as a medium of communication between the client and the server.

What are Soap webservices?

SOAP stands for Simple Object Access Protocol. It is an XML based messaging protocol. It helps in exchanging information among computers.

How do we Represent A resource in REST

Using HTTP methods

Can you use POST request instead of PUT to create a resource?

Yes, we can, because POST is Super set of all other HTTP methods except GET.

What do you understand by payload in restful Web Services?

Payload/Body is the secured input data which is sent to API to process the request. Payload is generally represented in JSON format in Rest API's.

What is Rest Assured.

It is Java Library which can automate REST API's.

How would we define API details in Rest Assured Automation?

we shall define all the request details and send it to server in GIVEN, WHEN & THEN methods.

What is Json serialization & Deserialization in Rest Assured.

Serialization in Rest Assured context is a process of converting a Java Object into Request body(payload).

Rest Assured also supports deserialization by converting Response body back to java Object.

List out few common Json Parsing Techniques used in Rest Assured Automation?

Json Path Deserialization of Json using POJO classes.

How would you send attachments to API using Rest Assured Test?

Using MultiPart Method.

Different Status Code & their description :-

200 OK The request was successfully completed

201 Created A new Resources was successfully created.

400 Bad Request The request was invalid

401 unauthorized The request did not include an authentication token or the authentication token was expired

403 forbidden The client did not have permission to access the requested resource

404 Not Found The requested resource was not found

405 Method not allowed The HTTP methods in the request was not supported by the resource.

409 Conflict The request could not be completed due to a conflict.

500 Internal server Error The request was not completed due to an internal error on server side.

503 Service Unavailable The server was unavailable.

Monday, 15 March 2021

Reflection In Java



Reflection in java





Java Reflection :- In Java, reflection allows us to inspect and manipulate classes, interfaces, constructors, methods, and fields at run time.

There is a class in Java named Class that keeps all the information about objects and classes at runtime.
The object of Class can be used to perform reflection.

What is the Java Reflection API?
1. Class Manipulator.
2. Used to manipulate classes and everything in a class.
3. can slow down a program because the JVM can't optimize the code.
4. Can't be used with applets.
5. Should be used sparingly.

Reflection of Java Classes

In order to reflect a Java class, we first need to create an object of Class.
And, using the object we can call various methods to get information about methods, fields, and constructors present in a class.

There exists three ways to create objects of Class:
1. Using forName() method
2. Using getClass() method
3. Using .class extension



Example 1:-
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.Class;

class vehicle
{
public void g()
{
System.out.println("I am Inside vehicle");
}
}
class car extends vehicle
{
public int x ;
public String name;
car()
{
System.out.println("i am inside constructor");
}
car(int x, int y)
{
System.out.println("Sum is " + (x+y));
}
public void j()
{
System.out.println("I am Inside car");
}
}
public class TestCsc3
{
public static void main(String args[]) throws ClassNotFoundException
{
car cr = new car();
Class cobj = cr.getClass();
TestCsc3 tc = new TestCsc3();
Class cobj2 = tc.getClass();
//get the name of class
String classname = cobj.getName();
System.out.println("Name of the class is " + classname);
//get super class
Class scla = cobj.getSuperclass();
System.out.println("Name of super class is " + scla.getName());
//get the constructor of the class
Constructor[] consname = cobj.getDeclaredConstructors();
for(Constructor c : consname)
{
System.out.println("Constructor name is :" +c.getName());
}
//get the modifier of the class
int modi = cobj2.getModifiers();
String modif = Modifier.toString(modi);
System.out.println("Modifier of class is " + (modif));
//get all the methods of the class
Method[] mth = cobj.getMethods();
for(Method m : mth)
{
System.out.println("Name is the methods" + m.getName());
}
//get declared methods of the class
Method[] mth2 = cobj.getDeclaredMethods();
for(Method m2 : mth2)
{
System.out.println("Name is the declared method is :-> " + m2.getName());
}
//get fields of class
Field[] fld = cobj.getDeclaredFields();
for(Field f : fld)
{
System.out.println("Name of the fiels is " + f.getName());
}
}
}

Output :-

i am inside constructor
Name of the class is practice.car
Name of super class is practice.vehicle
Constructor name is :practice.car
Constructor name is :practice.car
Modifier of class is public
Name is the methods j
Name is the methods g
Name is the methodswait
Name is the methodswait
Name is the methodswait
Name is the methodsequals
Name is the methodstoString
Name is the methodshashCode
Name is the methodsgetClass
Name is the methodsnotify
Name is the methodsnotifyAll
Name is the declared method is :-> j
Name of the fiels is x
Name of the fiels is name
-------------------------------------------------------------------------------------
Example 2:-

import java.lang.Class;
import java.lang.*;
class pent
{
}
public class Reflection2
{
public static void main(String[] args) throws ClassNotFoundException
{
Class c = Class.forName("practice.pent");
System.out.println("the name is class " + c.getName());
}
}

Output :-
the name is class practice.pent

Wednesday, 17 February 2021

Blackbox Testing Technique



Hello Friends,
Here we will learn the black box testing test case design technique :-
Decision Table Testing :-
1). Decision Table captures system requirements that contain logical conditions.
2). The specification are analyzed, and conditions and actions of the system are identified in a tabular form.
3). The input conditions and actions are most often stated in a way that they must be true or false.

Decision table technique is one of the widely used case design techniques for black box testing. This is a systematic approach where various input combinations and their respective system behavior are captured in a tabular form.
That's why it is also known as a cause-effect table. This technique is used to pick the test cases in a systematic manner; it saves the testing time and gives good coverage to the testing area of the software application.
Decision table technique is appropriate for the functions that have a logical relationship between two and more than two inputs.



Decision Table Example :

State Transition Diagram Testing technique :-
A state diagram – also known as state chart, state machine diagram or state transition diagram – visualises a sequence of states that an object can assume in its lifecycle. It is used to describe the behavior of a system, subsystem, component, or class.
state-transition diagram (STD) A diagram that indicates the possible states of a finite-state automaton and the allowable transitions between such states. ... Each one depicts the states, transitions, and event(s) that can cause each transition.





Orthogonal Array Testing
Orthogonal array testing is a systematic and statistical way of a black box testing technique used when number of inputs to the application under test is small but too complex for an exhaustive testing.

Orthogonal Array Testing Characteristics:
1)OAT, is a systematic and statistical approach to pairwise interactions.
2)Executing a well-defined and a precise test is likely to uncover most of the defects.
3)100% Orthogonal Array Testing implies 100% pairwise testing.

Consider a system which has three parameters {country; product; sales person} and each of them has three values. To test all the possible combinations of these parameters (i.e. exhaustive testing) we will need a set of 33 = 27 test cases. But instead of testing the system for each combination of parameters, we can use an orthogonal array to select only a subset of these combinations. Using orthogonal array testing, we can maximize the test coverage while minimizing the number of test cases to consider. We here assume that the pair that maximizes interaction between the parameters will have more defects and that the technique works.

Orthogonal array
Test case ↓ Country Product Salesperson
TC-1 DE Notebook Charlie
TC-2 DE Desktop Bob
TC-3 DE Mouse Alice
TC-4 US Notebook Bob
TC-5 US Desktop Alice
TC-6 US Mouse Charlie
TC-7 GB Notebook Alice
TC-8 GB Desktop Charlie
TC-9 GB Mouse Bob


Sunday, 31 January 2021

Various Software Development Model Waterfall Model V model etc



Hello friends
In this Article we will learn that how many working software models are being used in IT industries also what all the drwabacks they have and why do have many Software Development models?? due to usage or need of business requirement we use different models:-
1). WaterFall Model :- The Waterfall Model was the first Process Model to be introduced. It is also referred to as a linear-sequential life cycle model. It is very simple to understand and use. In a waterfall model, each phase must be completed before the next phase can begin and there is no overlapping in the phases.

The Waterfall model is the earliest SDLC approach that was used for software development.

The waterfall Model illustrates the software development process in a linear sequential flow. This means that any phase in the development process begins only if the previous phase is complete. In this waterfall model, the phases do not overlap.

Waterfall model is an example of a Sequential model. In this model, the software development activity is divided into different phases and each phase consists of a series of tasks and has different objectives.

Waterfall model is the pioneer of the SDLC processes. In fact, it was the first model which was widely used in the software industry.





Prototype Model :-

Prototype model should be used when the desired system needs to have a lot of interaction with the end users. Typically, online systems, web interfaces have a very high amount of interaction with end users, are best suited for Prototype model.
Prototyping is defined as the process of developing a working replication of a product or system that has to be engineered. ... In this process model, the system is partially implemented before or during the analysis phase thereby giving the customers an opportunity to see the product early in the life cycle.
This model is flexible in design.
It is easy to detect errors.
We can find missing functionality easily.
There is scope of refinement, it means new requirements can be easily accommodated.
It can be reused by the developer for more complicated projects in the future.

Incremental and Iterative Approach
•In incremental development, the product is built through successive versions that arerefined and expanded with each iteration–
Three concepts underlie the incrementalapproach:
•The Initialization Step
•The Control List
•The Iteration Step


Throwaway Approach
•In the incremental approach,
–the initial prototype is revised and refinedrepeatedly until it becomes the final product.

•In the throwaway approach,
–the prototype is discarded after the stakeholdersin the development are confident that they havearrived at the correct specifications and thedevelopment on the “real” product can start.



Incremental Model :- The incremental build model is a method of software development where the product is designed, implemented and tested incrementally until the product is finished. It involves both development and maintenance. The product is defined as finished when it satisfies all of its requirements.
Incremental Model is a software development process where requirements are divided into several stand-alone software development modules. In this example, each module passes through the requirement, design, development, implementation, and testing phases.


This model can be used when the requirements of the complete system are clearly defined and understood. Major requirements must be defined; however, some details can evolve with time. There is a need to get a product to the market early. A new technology is being used.



2). Spiral Model :- The spiral model combines the idea of iterative development with the systematic, controlled aspects of the waterfall model. This Spiral model is a combination of iterative development process model and sequential linear development model i.e. the waterfall model with a very high emphasis on risk analysis. It allows incremental releases of the product or incremental refinement through each iteration around the spiral.

The spiral model is a risk-driven software development process model. Based on the unique risk patterns of a given project, the spiral model guides a team to adopt elements of one or more process models, such as incremental, waterfall, or evolutionary prototyping

Spiral Model - Design The spiral model has four phases. A software project repeatedly passes through these phases in iterations called Spirals.
Identification
This phase starts with gathering the business requirements in the baseline spiral. In the subsequent spirals as the product matures, identification of system requirements, subsystem requirements and unit requirements are all done in this phase. This phase also includes understanding the system requirements by continuous communication between the customer and the system analyst. At the end of the spiral, the product is deployed in the identified market.

Design
The Design phase starts with the conceptual design in the baseline spiral and involves architectural design, logical design of modules, physical product design and the final design in the subsequent spirals.

Construct or Build
The Construct phase refers to production of the actual software product at every spiral. In the baseline spiral, when the product is just thought of and the design is being developed a POC (Proof of Concept) is developed in this phase to get customer feedback. Then in the subsequent spirals with higher clarity on requirements and design details a working model of the software called build is produced with a version number. These builds are sent to the customer for feedback.

Evaluation and Risk Analysis
Risk Analysis includes identifying, estimating and monitoring the technical feasibility and management risks, such as schedule slippage and cost overrun. After testing the build, at the end of first iteration, the customer evaluates the software and provides feedback.

The following illustration is a representation of the Spiral Model, listing the activities in each phase.

.


3). V Model :- In software development, the V-model represents a development process that may be considered an extension of the waterfall model, and is an example of the more general V-model. Instead of moving down in a linear way, the process steps are bent upwards after the coding phase, to form the typical V shape.
V Model is a highly disciplined SDLC model in which there is a testing phase parallel to each development phase. The V model is an extension of the waterfall model in which testing is done on each stage parallel with development in a sequential way. It is known as the Validation or Verification Model.
The V-model is a graphical representation of a systems development lifecycle. It is used to produce rigorous development lifecycle models and project management models.
What is V & V Testing??
In software project management, software testing, and software engineering, verification and validation (V&V) is the process of checking that a software system meets specifications and that it fulfills its intended purpose. It may also be referred to as software quality control.


4). Agile Model :- Agile SDLC model is a combination of iterative and incremental process models with focus on process adaptability and customer satisfaction by rapid delivery of working software product. Agile Methods break the product into small incremental builds. These builds are provided in iterations.
Agile modeling is a methodology for modeling and documenting software systems based on best practices. It is a collection of values and principles, that can be applied on an software development project.
Well executed Agile software development methodology helps teams significantly improve the quality of their software at each release. Not only that, it allows teams to adapt to change quickly. The Agile process consists of short, time-boxed iterations known as sprints. Each sprint results in a working product.
The 12 Agile Principles: What Are They and Do They Still Matter? Early and Continuous Delivery of Valuable Software. ...
Embrace Change. ...
Frequent Delivery. ...
Business and Developers Together. ...
Motivated Individuals. ...
Face-to-Face Conversation. ...
Working Software. ...
Technical Excellence.





Sunday, 2 August 2020

Introduction of Jmeter and Basic definitions

Introduction of Java & Basic Definitions




Introduction JMeter is the best open-source load testing tool to measure the performance of an application.

jMeter is an Open Source testing software. It is 100% pure Java application for load and performance testing.

jMeter is designed to cover various categories of tests such as load testing, functional testing, performance testing, regression testing, etc., and it requires JDK 6 or higher.

Performance Testing :-
In software quality assurance, performance testing is in general a testing practice performed to determine how a system performs in terms of responsiveness and stability under a particular workload.

Speed – It Checks whether the response of the application is fast.

Scalability – It determines the maximum user load.

Stability – It checks if the application is stable under varying loads.

Performance Testing Techniques:

Load testing - It is the simplest form of testing conducted to understand the behavior of the system under a specific load. Load testing will result in measuring important business critical transactions and load on the database, application server, etc., are also monitored.
Stress testing - It is performed to find the upper limit capacity of the system and also to determine how the system performs if the current load goes well above the expected maximum.
Soak testing - Soak Testing also known as endurance testing, is performed to determine the system parameters under continuous expected load. During soak tests the parameters such as memory utilization is monitored to detect memory leaks or other performance issues. The main aim is to discover the system's performance under sustained use.
Spike testing - Spike testing is performed by increasing the number of users suddenly by a very large amount and measuring the performance of the system. The main aim is to determine whether the system will be able to sustain the workload.

Attributes of Performance Testing:

Speed
Scalability
Stability
reliability

Connection Time : Time to connect to Server from client

Response Time : Response time is a measure of how responsive an application or subsystem is to a client request.

Throughput : Throughput indicates the number of transactions per second an application can handle, the amount of transactions produced over time during a test. Requests per second, calls per dat, hits per second, report per year etc.

Scenarios : Scenarios In the context of performance testing, a scenario is a sequence of steps in your application. A scenario can represent a use case or a business function such as searching a product catalog, adding an item to a shopping cart, or placing an order.

Bottleneck:Bottleneck used to describe a single part of a system that prevents further processing or significantly degrades the performance of the system as a whole.

Capacity:The degree to which a system can perform data processing until performance degrades. For example, the number of new customers being added to a database.

Concurrency: Normally this means the number of simultaneous virtual users driving transactions across the user journeys in a given performance test scenario but can also mean the number of transactions synchronized to happen at exactly the same point.

Key Performance Indicators(KPI):The set of targets which set the expected performance targets within the production system. These may include page response time(e.g. 99% of pages loaded <= 2 seconds), user concurrency, batch processing times, data throughput volumes, transaction failure rates and underlying infrastructure behavior(e.g. Maximum average CPU used, minimum free memory available, threshold for remaining physical storage/disk usage, logging space etc.)

Load Testing :-A type of performance testing used to evaluate the behavior of a system or component when the load on the system(via users and transaction) progressively increase up to and including peak levels.

Non-functional Requirements NFRs requirements that do not relate to the functioning of the system but to other aspects of the system such as reliability, usability and performance.

Performance Engineering:Activities designed to ensure a system will be designed and implemented to meet specific non malfunction requirements. Often takes place following completion of testing activities that highlight weaknesses in the design and implementation.

Performance Test Plan:-Typically a written document that details the objectives, scope, approach, deliverable, schedule, risk, data and test environment needs for testing on a specific project.

Performance Testing:-Testing designed to determine the performance level of a system.

Reliability :Related to stability, reliability is the degree to which a system provides the same result for the same action over time under load.

Scalability:The degree a which a system's performance and capacity can be increased typically by increasing available hardware resources with in a set of servers(vertical scaling) or increasing the number of servers available to services request (horizontal scaling)

Soak Testing:A type of performance testing used to evaluate the behavior of a system or component when the system is subjected to expected load over a sustained period of time.

Spike Testing: A type of performance testing used to evaluate the behavior of a system or component when subjected to large short-term changes in demand. Normally this is to test how the system responds to large increases in demand, e.g. User Logins, Black Friday-like scales events etc.

Stability:The degree to which a system exhibits failures and errors when under normal usage. For example, erroneous errors when registering new users under load.

Stress Testing:A type of performance testing used to evaluate the behavior of a system or component when subjected to load beyond the anticipated workload or by reducing the resources the system can use, such as CPU or memory.

Transaction Volume Model(TVM):A document detailing the user journeys to be simulated, the click-path steps that make up the user journeys and associated load/transaction volume models to be tested. This should include information regarding the geographical locale from where users will be expected to interact with the system and the method of interaction e.g. mobile vs desktop.

User Journey: The path through the system under test that a group of virtual users will use to simulate real users. It should be noted that key performance/volume impacting journeys should be used as it is impractical to performance test all possible User journeys, a good rule-of-thumb is to use the 20% of user journeys that generate 80% of the volume.

Virtual User:A simulated user that performs actions as a real user would during the execution of a test.

Thursday, 28 May 2020

How to Handle Tool Tip in selenium




Hello friends
In this Article we will learn that how to handle the tooltip operation in selenium, so while automating your website you will get 2 kind of below scenarios :-
1). Tool tip in title tag :- We will use getAttribute("title")

2). Tool tip inside div or any other html tag :- we will use here actions class.
Here is the code for both


import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class Tooltiptest {
WebDriver driver;
@BeforeTest
public void g() throws InterruptedException
{
/*System.setProperty("webdriver.chrome.driver", "D:\\Selenium\\Complete selenium\\ChromeDriver\\83\\chromedriver.exe");
System.setProperty("webdriver.chrome.silentOutput", "true");
driver = new ChromeDriver();*/
System.setProperty("webdriver.gecko.driver", "D:\\Selenium\\geckodriver\\new\\geckodriver.exe");
System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE, "null");
driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.navigate().to("file:///D:/Selenium/Complete%20selenium/tooltip/tooltip.html");
Thread.sleep(3000);
}
@Test
public void gettootltip() throws InterruptedException
{
WebElement tootipelement = driver.findElement(By.className("tooltip"));
Actions action = new Actions(driver);
action.moveToElement(tootipelement).build().perform();
String text = driver.findElement(By.className("tooltiptext")).getText();
System.out.println(text);
Thread.sleep(3000);
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
WebElement element = driver.findElement(By.xpath("/html/body/form/input[1]"));
String text2 = element.getAttribute("title");
System.out.println(text2);
}
}


Few More

Encapsulation in Python

Encapsulation in Python: A Complete Guide with Examples and Diagrams Encapsul...

Popular Posts