Showing posts with label Interview. Show all posts
Showing posts with label Interview. Show all posts

Tuesday, 2 April 2024

Agile & Scrum

 AGILE VALUES

  • Individuals and interactions OVER processes and tools
  • Working software OVER comprehensive documentation
  • Customer collaboration OVER contract negotiation
  • Responding to changes OVER following a plan

Agile Principles

    1. Our highest priority is to satisfy the customer through early and continuous deliver of valuable software.

    2. Welcome changing requirements, even late in development. Agile processes harness change for the customer’s competitive advantage.

    3. Delivery working software frequently, from a couple of weeks to a couple of months, with a preference to the shorter timescale.

    4. Business people and developers must work together daily throughout the project.

    5. Build projects around motivated individuals. Give them the environment and support they need, and trust them to get the job done.

    6. The most efficient and effective method of conveying information to and within a development team is face-to-face conversation.

    7. Working software is the primary measure of progress.

    8. Agile processes promote sustainable development. The sponsors, developers, and users should be able to maintain a constant pace indefinitely.

    9. Continuous attention to technical excellence and good design enhances agility.

    10. Simplicity – the art of maximizing the amount of work not done – is essential.

    11. The best architectures, requirements, and designs emerge from self-organizing teams.

    12. At regular intervals, the team reflects on how to become more effective, then tunes and adjusts it behavior accordingly.

# Define Scrum

Scrum is a lightweight framework that helps people, teams and organizations generate value through adaptive solutions for complex problems. Scrum employs an iterative, incremental approach to learn and adapt on the go, and create the highest value within the shortest time.

  • Product Backlog Refinement 
  • Product Backlog - Product Owner - Commitments 1 - Product Goal
  • Sprint Planning 
  • Sprint Backlog - Commitments 2 - Sprint Goal
  • Sprint - Scrum Team - Scrum Master - Product Owner - Developers
  • Daily Scrum 
  • Increment - Commitments 3 - Definition of Done
  • More Increments 
  • Sprint Review - Explore the Product, Impact and Adept
  • Spring Retrospective - Learnings, Opportunities and Experiments 


THREE ACCOUNTABILITIES 

  1. Developers
  2. Product Owner
  3. Scrum Master

FIVE EVENTS

  1. Sprint
  2. Sprint Planning
  3. Daily Scrum
  4. Sprint Review
  5. Sprint Retrospective

FIVE VALUES

  1.     Commitment
  2.     Focus
  3.     Respect
  4.     Openness
  5.     Courage





Object Oriented Programming In Java Questions And Answers - 3

 What is polymorphism?

  • Polymorphism is one of the major pillars of OOPs. 
  • It is a multiple form of a single entity.
  • It is process of performing a single task in different ways.
  • In polymorphism, one method have multiple forms based on the type of parameters, order of parameters, and number of parameters.
  • In simple words, Polymorphism is the ability of an object to take many forms. 

What are the types of polymorphism?

There are two types of polymorphism -

• Compile time polymorphism

• Run time polymorphism

What is compile time polymorphism?

  • The polymorphism that takes place during compile time is called compile time polymorphism. 
  • It is also called static polymorphism or early binding.
  • In this type of polymorphism, a class contain multiple methods having same name but different signatures.
  • Example of CTP - Method Overloading, Operator Overloading. 

What is runtime polymorphism? 

  • The polymorphism that takes place during run time is called compile time polymorphism. 
  • It is also called dynamic polymorphism or late binding. 
  • Runtime polymorphism refers to the process when a call to an overridden process is resolved at the run time.
  • In this type of polymorphism, the sub class and base class both contain methods having same name which can have different functionalities.

What is method overloading?

  • When a class contains multiple methods having same name but different signature, this is called method overloading. 
  • In method overloading, multiple methods of same names performs different tasks within the same class.
  • It depends upon the number and type of argument in the argument list and doesn't depend upon the return type of the method.
  • This is an example of compile time polymorphism. 
  • What is method overriding? 
  • When base class contain a method and sub class also contain same name method of its parent class, this is called method overriding. 
  • In other words, base class and subclass both have same name methods as well as signatures too. 
  • Method overriding is an example of run time polymorphism. 
  • Method overriding is used to provide the specific implementation of a method which is already provided by its superclass. 

What is operator overloading?

  • Operator overloading is a mechanism in which the operator is overloaded to provide the special meaning to the userdefined data type.
  • It is an example of compile time polymorphism. 

What is static function? 

  • Static functions are those functions that can be called without creating an object of the class. 
  • That means, Static methods do not use any instance variables of any object of the class they are defined in. 
  • Static methods can not be overridden. They are stored in heap space of the memory. 

What are virtual functions? 

  • Virtual function is a function or method used to override the behavior of the function in an inherited class with the same signature to achieve the polymorphism. Virtual function defined in the base class and overridden in the inherited class.
  • The Virtual function cannot be private, as the private functions cannot be overridden. 
  • It is used to achieve runtime polymorphism. 

 What are pure virtual functions? 

  •  A pure virtual function is that function which have no definition. 
  •  That means a virtual function that doesn't need implementation is called pure virtual function.
  •  A pure virtual function have not definitions but we must override that function in the derived class, otherwise the derived class will also become abstract class. 

 What is Constructor? 

  •  Constructor is a special type of member function which is used to initialize an object. 
  •  It is similar as functions but it's name should be same as its class name and must have no explicit return type.
  •  It is called when an object of the class is created. 
  •  At the time of calling constructor, memory for the object is allocated in the memory.
  •  We use constructor to assign values to the class variables at the time of object creation. 

 What are the types of Constructor?

 Constructor have following types -

  • Default constructor

  • Parameterized constructor

  • Copy constructor

  • Static constructor

• Private constructor

What is default constructor? 

A constructor with 0 parameters is known as default constructor. 

What is parameterized constructor?

The constructor method having the argument list or parameter list is called as parameterized constructor as it initializes the fields with the values of the parameters. 

What is copy constructor? 

A copy constructor is that constructor which use existing object to create a new object. It copy variables from another object of the same class to create a new object. 

What is static constructor? 

  • A static constructor is automatically called when the first instance is generated, or any static member is referenced.
  • The static constructor is explicitly declared by using a static keyword. 
  • However, the static constructor is not supported in Java. 

What is private constructor? 

  • Java enables us to declare a constructor as private. 
  • We can declare a constructor private by using the private access specifier. 
  • Note that if a constructor is declared private, we cannot create an object of the class.
  • Instead, we can use this private constructor in Singleton Design Pattern. 

What is destructor?

  • Destructor is a type of member function which is used to destroy an object. 
  • It is called automatically when the object goes out of scope or is explicitly destroyed by a call to delete.
  • It destroy the objects when they are no longer in use. 
  • A destructor has the same name as the class, preceded by a tilde (~). 

What is Constructor Overloading? 

  • The constructor method of the class may or may not have the argument list, and it has no return type specified and
  • we also know that method overloading depends only on the argument list and not on the return type. 
  • Thus, we can say that the constructor method can be overloaded. 

Wednesday, 27 March 2024

Where you applied OOPS in your automation framework?

1. #Encapsulation:

Data Hiding: Keeping some of the internal states of objects hidden from the outside, exposing only what's necessary.
Test Configuration: You might have a configuration class that encapsulates all the configurations, so changes to configurations can be made in one place.

2. #Abstraction:

WebDriver Abstraction: Instead of directly interacting with WebDriver methods everywhere in your code, you might have an abstract layer that defines actions like #click(), #type(), etc. This way, if the WebDriver API changes, you only need to make changes in one place.
Page Object Model (POM): Each web page or a component of a web page can be represented as a class. The methods in this class represent the actions that can be performed on the page.

3. #Inheritance:

Base Test Class: This might contain common setup, teardown, and utility methods that other specific test classes inherit, so you don’t have to rewrite common procedures.
Common Web Components: If there are common components (like headers, footers) across pages, you can create a base page class that other page classes inherit from.

4. #Polymorphism:

Multiple Browsers Support: If your framework supports tests on multiple browsers, you might have a generic #browser interface (or abstract class) and then specific implementations like #ChromeBrowser, #FirefoxBrowser, etc. The actual browser-specific operations are then done polymorphically.

5. #Composition 

(though not one of the "main four" OOP principles, it's important in OOP design):
Combining Components: Instead of inheriting everything from a base class, you might use composition to combine multiple smaller classes (components) to create a more complex class. For instance, a #TestPage class might be composed of a #HeaderComponent, #FooterComponent, and #MainContentComponent.

When designing an automation framework using OOP principles, the aim is to make the code more modular, maintainable, reusable, and scalable. Using OOP effectively can lead to a more organized and efficient automation suite.

Step-by-Step guide to scheduling jobs in Jenkins:

 Scheduling jobs in Jenkins is a fundamental task, especially for QA (Quality Assurance) processes. 

1. Access Jenkins Dashboard:

 - Open a web browser and navigate to your Jenkins instance's URL.

 - Log in to Jenkins with your credentials to access the Jenkins dashboard.

2. Create or Select Job:

 - If you haven't already created the job for your QA tasks, you can create one by clicking on "New Item" on the Jenkins dashboard.

 - Enter a name for your job, select the type of job (e.g., Freestyle project, Pipeline), and click "OK."

 - If you already have a job configured for your QA tasks, navigate to it from the Jenkins dashboard.

3. Configure Job:

 - Configure your job according to your QA requirements. This may include defining build steps, setting up test execution, configuring post-build actions, etc.

 - Ensure that your job performs the necessary QA tasks such as running tests, static code analysis, or any other quality checks.

4. Schedule Build:

 - In the job configuration page, locate the "Build Triggers" section.

 - Check the option for "Build periodically."

 - In the "Schedule" field, specify the cron syntax to define when the job should be triggered. For example, to run the job every day at midnight, you can use `0 0 * * *`.

 - You can use Jenkins' built-in help or search online for cron syntax if you're not familiar with it.

5. Save Configuration:

 - Once you've configured the schedule, scroll down to the bottom of the job configuration page and click "Save" to apply the changes.

6. Monitor Execution:

 - Jenkins will now automatically trigger the job based on the schedule you've configured.

 - Monitor the job executions from the Jenkins dashboard to ensure that your QA tasks are being performed as expected.

Ways to Pass Payloads in Rest Assured for API Automation

 Various ways we can pass payloads to our HTTP methods (POST, PUT, UPDATE) for API automation using Rest Assured. 

1. Inline Payload:

This method involves directly passing the payload as a string within the request body. It is suitable for smaller payloads and can be implemented easily using Rest Assured's request specification.

2. External JSON File:

For larger payloads or when reusability is important, storing the payload in an external JSON file is a good approach. Rest Assured allows you to read the JSON file and pass it as the request body. This method enhances code readability and simplifies maintenance.

3. POJO (Plain Old Java Object):

In this approach, you create a Java class that maps to the structure of your payload. Rest Assured can serialize the POJO into JSON/XML and pass it as the request body. This method is beneficial when working with complex and nested payload structures, as it provides strong typing and better code organization.

4. Map or HashMap:

If your payload is relatively simple and doesn't require a predefined structure, you can use a Map or HashMap to represent the payload key-value pairs. Rest Assured will automatically convert the Map into JSON/XML and send it as the request body.

5. Serialization Libraries (GSON, Jackson):

Rest Assured seamlessly integrates with popular JSON serialization libraries like GSON and Jackson. You can use these libraries to convert Java objects or Maps into JSON and pass them as the request body. This approach offers more flexibility and customization options.

6. Form Parameters:

For form data submission, Rest Assured supports adding form parameters to the request. You can use the `.formParam()` method to pass key-value pairs, which will be encoded as application/x-www-form-urlencoded.

Most asked QA interview question

 1.What is the use of POM.XML?

 Use of pom.xml:

 -  pom.xml stands for "Project Object Model" and is a fundamental part of Apache Maven, a popular build automation tool primarily used for Java projects.

 - The  pom.xml file contains project configuration information and acts as a blueprint for building the project.

 - Key uses of  pom.xml include:

 - Defining project metadata such as group ID, artifact ID, version, and dependencies.

 - Specifying build settings like plugins, goals, and profiles.

 - Managing project dependencies and transitive dependencies.

 - Declaring repositories where Maven can download dependencies.

 - Configuring project-specific settings like source directories, output directories, and build lifecycle phases.


 Overall,  pom.xml serves as a central configuration file that Maven uses to manage and build the project, ensuring consistency and reproducibility across different environments.


 2. What is the use of testng.xml?

 Use of testng.xml:

 - testng.xml is a configuration file used specifically with TestNG, a popular testing framework for Java.

 - The  testng.xml file allows users to define the test suite and configure various aspects of test execution.

 - Key uses of  testng.xml include:

 - Defining test suites: You can specify which test classes or test methods should be included or excluded from the test suite.

 - Configuring test parameters: You can set parameters for test methods or classes, which can be accessed during test execution.

 - Specifying test groups: You can group test methods or classes and selectively run tests based on these groups.

 - Configuring test execution settings: You can define parallel execution, thread counts, timeout settings, and other execution-related parameters.

 - Setting up listeners: You can configure listeners to monitor test execution and perform actions based on test events.


 - Overall,  testng.xml provides a flexible and customizable way to configure and run tests using TestNG.

SQL Interview Questions Commonly Asked for QA

Basic SQL Queries:

  Fetch all columns from a table:

   SELECT * FROM table_name;

  Get distinct values from a column:

   SELECT DISTINCT column_name FROM table_name;

  Retrieve top N records from a table:

   SELECT * FROM table_name LIMIT N;


Filtering and Sorting:

  Filter rows where a column equals a value:

   SELECT * FROM table_name WHERE column_name = value;

  Filter rows within a range:

   SELECT * FROM table_name WHERE column_name BETWEEN value1 AND value2;

  Retrieve rows with NULL values in a column:

   SELECT * FROM table_name WHERE column_name IS NULL;

  Sort result set in ascending/descending order:

   SELECT * FROM table_name ORDER BY column_name ASC/DESC;


Aggregate Functions:

  Count total rows:

   SELECT COUNT(*) FROM table_name;

  Calculate average, sum, min, max:

   SELECT AVG(column_name), SUM(column_name), MIN(column_name), MAX(column_name) FROM table_name;

  Group and calculate aggregates:

   SELECT column_name, AVG(salary) FROM table_name GROUP BY column_name;


Joins:

  INNER, LEFT, RIGHT, FULL joins explained:

   INNER: Retrieve common rows from both tables.

   LEFT: All rows from the left table and matching rows from the right.

   RIGHT: All rows from the right table and matching from the left.

   FULL: All rows from both tables.

  Retrieve data from multiple tables:

   SELECT * FROM table1 JOIN table2 ON table1.column_name = table2.column_name;


Subqueries:

  Using a subquery to retrieve data:

   SELECT * FROM table_name WHERE column_name IN (SELECT column_name FROM another_table);

  Comparing values between tables:

   SELECT * FROM table1 WHERE column_name = (SELECT column_name FROM table2 WHERE condition);

Data Modification:

  Insert new record:

   INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...);

  Update records:

   UPDATE table_name SET column_name = new_value WHERE condition;

  Delete records:

   DELETE FROM table_name WHERE condition;


Table Design and Constraints:

  Primary key vs. Foreign key differences:

   Primary key uniquely identifies a record, while a foreign key links to another table's primary key.

  Design a table schema:

   Create table with appropriate columns, primary keys, and foreign keys.

Advanced Queries:

  Retrieve the nth highest (or lowest) value:

   SELECT column_name FROM table_name ORDER BY column_name DESC LIMIT n-1, 1;

 

Scenario Based Frequently Asked Interview Q&A on TestNG

Scenario: Handling Flaky Tests

Question: How would you deal with flaky tests in your Selenium automation suite using TestNG?

Answer: To address flaky tests, I would implement retry logic in TestNG. By using the retryAnalyzer feature in TestNG, I can specify a custom retry analyzer class that determines whether a failed test should be retried based on certain conditions, such as specific exceptions or test result statuses. This helps improve the reliability of the test suite by rerunning failed tests automatically.

Scenario: Parallel Execution

Question: Explain how you would implement parallel execution of tests in TestNG for faster execution in your Selenium automation framework.

Answer: TestNG allows running tests in parallel, either at the suite or test level, by organizing them into different suites and configuring parallel attributes like "parallel" and "thread-count".

<suite name="MyTestSuite" parallel="tests" thread-count="5">

<!-- Test configurations -->

</suite>

Scenario: Data-Driven Testing

Question: Describe how you would perform data-driven testing using TestNG in your Selenium automation framework.

Answer: TestNG supports data-driven testing through its @DataProvider annotation, which allows me to supply test data from external sources such as Excel sheets or databases. I can create a method annotated with @DataProvider to provide test data, and then annotate my test methods with @Test(dataProvider) to execute the tests with different data sets. This enables to execute the same test logic with multiple input values and verify the expected behavior.

@DataProvider(name = "loginData")

public Object[][] getLoginData() {

return new Object[][] {

{"user1", "pwd1"},

{"user2", "pwd2"},

};

}

@Test(dataProvider = "loginData")

public void loginTest(String username, String password){}

Scenario: Grouping and Tagging Tests

Question: How would you group and tag tests in TestNG for better organization and selective execution in your Selenium automation framework?

Answer: TestNG allows grouping tests using the @Test(groups) annotation, enabling selective execution and better organization of test suites by defining groups in testng.xml. This allows for selective execution of tests and better organization of test suites like smoke, sanity, regression.

@Test(groups = {"smoke", "regression"})

public void loginTest() {

// code

}

Friday, 22 March 2024

API Interview Preparation - 2

What is an API?

API stands for "Application Programming Interface".

It is a system that enables communication between different software.

You can think of it as two people speaking different languages communicating through an interpreter. API acts as an interpreter facilitating understanding between two different software and enabling data exchange.

Benefits of API:

  • Security: Establishes a secure connection between two different servers.
  • Speed: Speeds up data exchange.
  • Convenience: Facilitates software development.
  • Saving: Saves time and money.
  • Traffic: Increases the traffic of your website or application.
  • Visibility: Increases the visibility of your website or application.

Types of API:

  • Internal API: APIs used by specific individuals.
  • Open API: APIs open to everyone's use.
  • Partner API: APIs used between two companies.
  • Composite API: APIs that combine multiple APIs.

API Architectures:
  • REST API: The most commonly used API architecture.
  • SOAP API: A more secure API architecture.

Examples of APIs:

  • Google Ads API
  • Facebook API
  • YouTube API
  • WhatsApp Business API

Examples:

  • Automatic synchronization of a website and a mobile application.
  • Integration of an e-commerce site with payment infrastructure.
  • Connection of a social media platform with other platforms.

Request

The areas we need to check when preparing an API Request: (*) Mandatory fields.

1. HTTP Request Types (Get, Post, Put - Patch, Delete)*
2. Base URL*
3. Endpoint*
4. Request Headers (Location for Additional Information)
5. Params
a. Path
b. Query
6. Request Body (Mandatory for Post)
7. Authorization, Authentication (Token)

Response

1. Status Code

a. 1xx: The server acknowledges receiving your request and starts processing it.

b. 2xx: The server indicates that it has successfully received, understood, and accepted your request.

i. (200  Ok, 201  Created, 202 Accepted, 204  No Content)

c. 3xx: Indicates that additional steps are required to complete your request.

d. 4xx: The server cannot process your request because you may have made it incorrectly.

i. (400-Bad Request, 401-Unauthorized, 403-Forbidden, 404-Not Found, 405-Method not Allowed)

e. 5xx: Indicates that the server cannot process your request due to a server error.

2. Response Headers

3. Response Body (Json) // There are 6 ways to verify the Body.

Validation Response Body

1. response.asString();

2. response.path("GPATH SYNTAX")

3. Jsonpath jsonpath = response.jsonpath();

Jsonpath.getString("GPATH SYNTAX")

4. HamCrestMatchers

RestAssured.

 .given()

 .when()

 .get("BASEURL + ENDPOINT")

.then()

5. Json to Java with as() method --> DE-SERIALIZATION

6. POJO (PLAIN OLD JAVA OBJECT)

Authentication - Authorization

Authentication - Who is this?

401: Invalid credentials

401: Unauthorized

The API doesn't know who you are.

Authorization - Give permissions

403: You don't have sufficient privileges to perform the operation.

403: Forbidden

The API allows entry but with limited privileges.

API Architectures

API architectures are a set of principles and rules that determine how APIs are designed and developed.

Different API architectures have different advantages and disadvantages. The most commonly used API

architectures are as follows:

1. REST API (Representational State Transfer):

  • It is the most widely used API architecture.
  • It is simple and easy to use.
  • It utilizes HTTP methods (GET, POST, PUT, DELETE).
  • It uses data formats such as JSON or XML.
  • It is scalable and flexible.

2. SOAP API (Simple Object Access Protocol):

  • It is a more secure API architecture.
  • It is XML-based.
  • It uses standards such as WSDL (Web Service Definition Language).
  • It is more complex and harder to use.

REST: Preferred when speed, flexibility, and simplicity are important.

SOAP: Preferred in situations where security and error management are critical. 

API vs Web Services?

 Both APIs (Application Programming Interfaces) and Web Services are ways to communicate between applications. However, they have some important differences:

API (Application Programming Interface)

  • Scope: APIs are more general concepts. They are software interfaces used for any communication protocol and data exchange.
  • Protocols: They can use various protocols including REST, SOAP, GraphQL, and more.
  • Formats: APIs support JSON, XML, and other data formats.
  • Flexibility: APIs are more flexible architecturally and provide a broader range of interaction betweenapplications on different platforms.

Web Services

  • Nature: Web services are a specific subset of APIs.
  • Protocols: They are inherently tied to specific web technologies. They use protocols like SOAP (usually transmitting data in XML format) and less commonly XML-RPC, UDDI, etc.
  • Standards: Web services have stricter standards and protocols.
  • Compatibility: When it comes to cross-platform compatibility with systems built on different technologies, web services may be more restrictive compared to APIs.

In Summary:

All Web Services are APIs, but not all APIs are Web Services. Web Services are more rigid and use mandatory protocols like SOAP and XML. SOAP APIs typically support an XML document called WSDL (Web Service Definition Language) that defines the functionality of the API.

APIs allow for more flexibility with architectures like REST, GraphQL, and offer more options for data formats like JSON.

Which One to Choose?

What you choose will depend on your objectives:

Integrating different platforms: If you need to work with legacy systems using SOAP and require more robust standards, web services might be appropriate.

High flexibility and different protocols: If you need a more flexible architecture or prefer lighter data formats like JSON, APIs are a better choice.

Additional Notes:

In modern usage, the term "API" often refers to web-based APIs like REST APIs. However, APIs do not require network connections (operating system libraries can also be considered APIs).

Web Services are now considered an older technology, and API types like REST have become more popular.

What is Serialization and Deserialization?

Serialization: Serialization is the process of converting the state or structure of an object or data structure in memory into a format suitable for storage. This process is typically done by converting an object or data structure into a format such as JSON, XML, or binary. Serialization allows an object's state to be transferred from memory to disk or over a network while preserving its state.

Summary:

It is the process of converting an object or data structure into a specific format for storage or transmission purposes.

Deserialization: Deserialization is the opposite of serialization. It involves converting data retrieved from a format (such as JSON or XML) back into its original object or data structure. This process allows data stored or transmitted on disk or over a network to be reconstructed by the program for use in memory.

Summary:

It is the process of converting a serialized object or data structure back into its original form. Serialization and deserialization are important parts of APIs and allow for data exchange by converting different data types into each other.

Why is it used?

Data Storage: Objects or data structures need to be serialized for storage on disk, in a database, or over a network.

Data Transmission: Objects or data structures need to be serialized to be transferred between different systems or applications.

Interoperability: A common format is used for data exchange between different programming languages and applications.

Example:

A Java application can serialize a user object to JSON format and send this JSON data to a web API.

The web API can deserialize the JSON data back to a user object using deserialization and store this object in a database.

What is an Endpoint?

  • It is a specific address that provides access to a service or resource.
  • An Endpoint is the entry point for a request made to an API.
  • Endpoints retrieve specific data or trigger operations that modify data on the server.
  • Endpoints specify the type of request using HTTP methods.

What are XML and JSON concepts?

XML (Extensible Markup Language): It is a markup language used to define and store data.

JSON (JavaScript Object Notation): It is a lightweight data interchange format used to represent data. Data is stored in a "Key" and "Value" format

  • Feature                         XML                                             JSON
  • Complexity         More complex.                                 Simpler.
  • Readability         Less readable.                             More readable.
  • Flexibility             Less flexible.                                 More flexible.
  • Performance         Slower.                                              Faster.
  • Data Types           Supports  more                         Supports fewer 

XML  Use CasesUsed in areas such as web services,  configuration files, data transmission.

JSON Use CasesUsed in areas such as web APIs, NoSQL databases, data interchange with JavaScript.

Gson

Gson is a Java library developed by Google for converting Java objects to JSON (serialization) and JSON to Java objects (deserialization).

  • JSON is a data interchange format, while Gson is a Java serialization/deserialization library.
  • JSON is simple and works across different platforms. Gson is specifically designed for Java and offers more flexibility

Swagger

Swagger is an open-source software used for designing, documenting, and testing APIs. With features like easy design and creation, standard format, and live testing, it makes your API more usable and developer-friendly.

How to Test an API?

As a tester we send a API request and verify the status code, response body and checking the endpoints of the api URL is working as expected

  • Pozitive - I send valid requests, headers, parameters, and JSON bodies, and verify that the response is 200/201.
  • Negative - I send invalid requests, headers, parameters, and bodies, expecting the response not to be 200.

How to Test a REST API?

  • API Validation: Making sure each REST API endpoint works as expected.
  • Postman: A popular API platform for manual testing.
  • Rest Assured: A library for automating API tests with Java

Methods:

  • HTTP Requests: Sending requests to API endpoints using various HTTP methods like POST, PUT, GET, DELETE.
  • Response Verification: Checking if the API returns the correct status codes (200, 400, 401, 500, etc.) and if the response content is as expected. Headers can also be verified.
  • Positive and Negative Testing:

    • Positive Tests: Testing with valid request parameters, headers, and JSON bodies to verify that the API works as expected in successful scenarios (200 status code and correct JSON response).
    • Negative Tests: Testing with invalid request parameters, headers, and JSON bodies to verify that the API handles error scenarios (non-200 status codes and error messages) correctly.

Summary:

Comprehensive testing using different HTTP methods. Preparation of positive and negative test scenarios. Verification of HTTP response codes, response bodies, and headers. Use of appropriate tools for manual testing (Postman) and automated testing (Rest Assured).

RestAssured

RestAssured is an easy-to-use, flexible, and comprehensive open-source library for testing REST APIs in Java. With RestAssured, you can test the functionality of API endpoints, verify expected responses and error codes, and create automated test scenarios.

JsonPath

One of the ways to verify the response body. 

Jsonpath jsonpath = response.jsonpath();


#APITesting  #QualityAssurance  #testautomation  #testing #automation #softwaretesting #qa #api #software








Salesforce AI Associate Certification - 3

What is semantic retrieval in the context of LLMs?   Searching for relevant information in other data sources What additional protection do...