Back to Blogs
Technology trends

Automation Testing Secrets and How to Simplify API Testing and Performance Testing

Every software development team tests its products, yet the software that is delivered is invariably defective. Even with the most advanced manual testing approaches, test engineers strive to detect flaws before the product is released. They always find their way in and usually return. Using test automation software is the most effective way to increase the efficacy, efficiency, and coverage of your software testing.

What is Automation Testing?

Automation testing is a software testing approach that executes a test case suite using particular automated testing software tools. Manual testing, on the other hand, is carried out by a human sitting in front of a computer, painstakingly carrying out the test processes.

The program may also insert test data into the System Under Test, compare predicted and actual outcomes, and create complete test reports. Software test automation necessitates significant financial and resource commitments.

Repeated execution of the same test suite will be required in subsequent development cycles. This test suite may be recorded and replayed as needed using a test automation tool. No human interaction is necessary after the test suite has been automated. This increased the ROI of test automation. The purpose of automation is to minimize the number of test cases that must be executed manually, not to completely remove manual testing.

Why test automation?

Test automation is the most effective method for increasing the efficacy, coverage, and speed of software testing. Here are some of the reasons why automated software testing is important:

  • Manual Testing of all workflows, fields and negative cases takes time and money.

  • Manually testing for multilingual sites is difficult.

  • In software testing, test automation does not require human intervention.

  • Unattended automated testing is possible (overnight)

  • Test automation accelerates test execution.

  • Automation aids in increasing test coverage.

  • Manual Testing can become tedious and thus error-prone.

How to Simplify API Testing and Performance Testing?

When the code is finished, it is tested against the specifications. Quality assurance is the focus of the SDLC testing phase. Identifying and repairing any erroneous code portions is also part of the testing process. 

1/ Develop a test strategy based on the software requirements

  • Identify available testing resources, including instructions and tester assignments, select test types, and report to technical executives. 

  • Improve test outcomes by collaborating with development teams. 

Even if you have automated testing tools in place, nothing beats a good testing session led by a skilled quality assurance team. So collect your testing team, put the product through its paces, record issues, and generally push the code to its limits. Return it to the developers to be rectified.

2/ We use Automation Test technologies and other Testing tools to ease API and Performance testing

(a) K6 for testing performance

K6 is an open-source load-testing tool that can be scripted in JavaScript (ES6), giving testers the freedom to write tests in a language that they understand. It interprets massive amounts of data generated by load tests, relieving clients of a significant amount of work that was previously the responsibility of performance engineers.

Benefits: 

- K6 consumes minimal amounts of system resources and has high performance. 

- With K6, you will be able to conduct different types of load tests, for example, maximum search tests, stress tests, or reliability tests. 

- Performance monitoring: K6 provides excellent opportunities for automating performance testing. You can run tests with a lighter load to constantly monitor the performance of the system.

- Fewer load generators needed. A single k6 process will efficiently use all CPU cores on a load generator machine. A single instance of k6 is often enough to generate load of 30.000-40.000 simultaneous users (VUs). This amount of VUs can generate upwards of 300,000 requests per second (RPS)

- No out of memory errors, k6 is also good for when you're short on time.

- No GUI means no resource overhead during load tests. GUIs typically add significantly more overhead to an application, which is one of the reasons why k6 doesn't have one.

 

(b) Postman for testing APIs utilizing a graphical user interface

Postman is an API platform that allows you to create and use APIs. Postman improves collaboration and simplifies each phase of the API lifecycle, allowing you to design better APIs quicker. 

Benefits:

- Keep the information in an orderly manner For subsequent API calls, you can use the stored response as part of a request header. You can use this when an API requires data that is received from another API. 

- Effective integration with systems Postman’s command-line tool makes it easy to integrate with build systems, such as Jenkins. 

- Convenient implementation of business logic On the Business logic layer, Postman testing improves the application test coverage. 

- On-the-fly testing Postman makes sure that there aren’t any bugs or typos by incrementally running the written code.

- Practical scripts You have the leverage to manipulate the received data in different ways as the test and test assertions are written in JavaScript. 

- Countless resources Postman also provides you with tons of code snippets with examples if you are new to writing test scripts.

-  Simple migration to code repositories You can use traditional file sharing to export a test collection and move it from the environment to the environment.

- Simple Test Suite Creation To ensure your API is working as expected you can easily create a collection of integration tests in Postman.  

- Able to perform tests in a variety of contexts Postman inserts the correct environment configuration into your test automatically and allows you to store specific information about different environments. 

- Multiple test data storage Postman permits you to store data from the previous test into global variables which can exactly be used as environmental variables for subsequent API calls.

(c) Beginning REST API testing with Serenity and Cucumber 

 

1- The initial project

The starting project on Github (https://github.com/serenity-bdd/serenity-rest-starter) is the ideal location to start with Serenity with Cucumber. This project includes a basic project setup, example tests, and supporting classes. The starting project includes a prototype SpringBoot web service as well as some Rest Assured-based tests. The project also shows how Freemarker may be used to prepare test data for your scenarios.

- The directory structure of the project: The project includes build scripts for both Maven and Gradle, and it adheres to the standard

- Including the reliance on Cucumber 4: Serenity works with both Cucumber 2.x and Cucumber 4. This flexibility, however, necessitates some tinkering with the build requirements.

If you are using Maven, you must perform the following steps:

- Remove the cucumber-core dependent from your serenity-core dependence.

- Replace the dependent on serenity-cucumber with the dependency on serenity-cucumber4.

- Include cucumber-java and cucumber-junit requirements from the Cucumber 4.x version in your project.

The following is an example of appropriately set dependencies: 

If you are using Gradle, you must use the resolutionStrategy element to guarantee that the 4.x version of cucumber-core is utilized, as well as the Cucumber 4.x versions of cucumber-java and cucumber-junit as described above:

The remainder of this essay will go through some of the highlights of both editions. Let's start with the master branch version, which employs lightweight page objects and actions.

2- A simple GET scenario

The project includes two simple situations, one demonstrating a GET and the other demonstrating a POST.

The first example puts the /api/status endpoint to the test:

Scenario: Application status end-point

Given the application is running

When I check the application status

Then the API should return "Serenity REST Starter project up and running"

This scenario's glue code exemplifies the tiered approach we've discovered works well for both web and non-web acceptance tests. The glue code is in charge of arranging calls to a layer of more business-focused classes that actually make the REST requests.

The real REST requests are made in the action classes, such as ApplicationStatus here, by utilizing RestAssured. These either utilize RestAssured (if we don't want the queries in the reports) or SerenityRest (if we do):

In steps that perform assertions, we can also use the SerenityRest.restAssuredThat() helper method lets us make a RestAssured assertion on the last response the server sent us:

3- A more complex scenario

The following is an example of a POST query:

The Given step employs a Freemarker template to merge the data in the Cucumber table with values defined in a properties file; for more information, see the MergeFrom class.

After preparing the message to be sent, we utilize another action class (tradingSystem) to publish it:

This query is posted to the end point by the RecordNewTrade class, as illustrated below:

The final step ensures that the whole cost has been appropriately reflected in the deal. In a real project, this would be done through another REST request or a database query, but we're demonstrating how to retrieve and compare tabular data from JSON answers here.

The TradeResponse class is in charge of getting the most recent REST response and turning it to a string map.

Application in practice

We have used automation testing extensively in customer projects. They are happy with the Testing technique. We'd like to use the testing process for the UpDiagram website - a project management tool in the digital era - as an example of Automation Testing.

A basic microservice that includes a test suite with tests for each stage of the test pyramid. The example application demonstrates common microservice characteristics. It offers a REST interface, communicates with a database, and retrieves data from a third-party REST service. It's built into Spring Boot and should be understandable even if you've never worked with it before. 

 

1/ Functionality

The application's functioning is straightforward. It has three endpoints and a REST interface:

GET /hello                 Returns "Project". Always

GET /hello/{name}     Looks up the project with the provided name. If the
                                   project is known, returns "Project {name}.

GET /done                Returns the current project conditions for archived 

 

2/ High-level Structure

On a higher level compared, the system is structured as follows:

Our microservice has a REST interface that can be accessed using HTTP. The service will retrieve information from a database for some endpoints. In other circumstances, the service will use HTTP to query and show current project conditions from an external projects API.

 

The Spring Service has a Spring-like architecture internally:

- Controller classes handle HTTP requests and answers and offer REST endpoints.

- Repository classes communicate with the database and handle data writing and reading to and from persistent storage.

- Client classes communicate with other APIs; in our example, it retrieves JSON from the updiagram.com projects API through HTTPS.

- Domain classes represent our domain model and domain logic (which, to be fair, is quite trivial in our case).

Summary

 

Automation Testing is a modern testing method that requires the QA/QC team to have competence and experience in capturing and developing test cases.

When applying Automation Testing technology, the project team will save a lot of time, costs, and resources. But currently, the number of QA/QC who know and use Automation Testing technology is not too much in the IT industry market. Fortunately, ITC Group's QA/QC engineers are well-trained and proficient in Automation Testing technology.

Contact us (or send email to sales@itcgroup.io) to immediately apply Automation Testing technology to your project.

 
Back to Blogs
Technology trends

Related articles

1 mins readTechnology trends
1 mins readTechnology trends
1 mins readTechnology trends
1 mins readTechnology trends
1 mins readTechnology trends
1 mins readTechnology trends