API Testing Made Effortless : KushoAI

devrx

Abhinav Pandey

Posted on October 14, 2024

API Testing Made Effortless : KushoAI

Ever wondered why we used grinders while our ancestors did all the grinding using bare hands? Enhanced technology helped us outperform the previous generation and automate daily day work which allowed us to focus more on other aspects of life which led to even more discoveries. Unlike how the present day Engineers sit down for hours trying to process all the information being passed in our API calls, you want to be more productive and focus more on processing the data to churn some useful code into real life utilities.

As a backend engineer, I understand the struggle of not fully grasping how API endpoint servers function — or more accurately, the frustration of not completely understanding (🤓) how our API endpoint servers function. Moreover, understanding optimal performance and testing runtime environments for your API endpoint unanimously becomes the TOP PRIORITY for Engineers. Hence, the way we test our APIs ultimately decides our speed, accuracy and our ability to catch bugs early on in our code.

Numerous questions may arise in your mind when thinking about why we need to test our APIs!! Although Test Driven Development may seem simple, it is one of the hardest and the most mischievous lifecycle a Developer may go through. Ultimately, the way we test our routes and handlers decides the way our data management lifecycle is going to proceed. That's when KushoAI comes in existence.

To be honest, I pondered upon KushoAI by accident while discovering AI agents that may help simplify my Development Cycle and I assure you. "Life as a Backend Engineer has never been as simple when testing my tools". But what exactly is KushoAI? Is is just "one of those overhyped" AI tools that just EXISTS? Is it actually useful? If yes, then how? The most important question that stands is : "What makes KushoAI superior to other AI Testing Agents". That's why I decided to create a Blog to help you understand how KushoAI works and what features it offers which makes it different from others!!

Well, going by the bookish definition as defined in their documentations : "KushoAI is an AI Agent for API testing which generates exhaustive test suites for your APIs in minutes – all you need to do is input your API information and sit back while KushoAI figures out what real-world scenarios can occur for your API in production and write ready-to-execute tests for them."

In simpler terms, you decide how you want to feed your input to the agent and receive a detailed and distinct Test Suite which checks how your API is going to function. Is that is? Obviously not, which is why I'm here putting my time blogging about this tool. Let's look at the most unique feature which KushoAI offers to Engineers.

KushoIntegrations


Test Suites Creation

(Different ways to create a test suite in KushoAI)

So, the first and the most exciting feature that the platform offers is diversity to choose your data input for API to create a test suite. The documentations for KushoAI specify that :

"A test suite is a collection of tests that KushoAI has generated for your API. On a high level, this is how test generation on KushoAI works:

  • You provide your API information to create a test suite in one of the formats specified below.
  • KushoAI looks at your API information and figures out what could possibly go wrong for an API like this.
  • Based on this information, KushoAI comes up with tests (which includes both scenarios and the API payload needed to execute the test) which will be available in the test suite for that API."

KushoAI provides 4 major ways to help you provide API input for test generations :

  1. Manually enter API details
  2. Import OpenAPI specs
  3. Import Postman Collections
  4. Copy and paste cURL command

Options to Upload

Out of these 4 ways, my favourite method has always been to Import Postman Collections. Although, I'd like to describe all the methods one by one in brief :

a) Manually Enter API Details

This is by far one of the most utilized methods on the platform due to its simplicity and ease of understanding. All you need to know is how your API endpoint was designed, including the Endpoint URL, Headers, Path Params, Query Parameters, and the Request Body for your specific API request. Once you enter this information, all that's left to do is click "Generate," and BOOM!! In just a couple of minutes, your API tests are generated.

Now, a common question might be: what exactly are these parameters if you're unfamiliar with the terms? Don’t worry—KushoAI has got you covered. The platform provides clear explanations of what these parameters are, using dummy API examples for easy understanding. Additionally, KushoAI offers a feature to create Groups of API suites, similar to how Collections work in Postman.

opt-1-1
opt-1-2
opt-1-3
opt-1-4

b) Import OpenAPI Specs

Once in our life we all have used services like Swagger for our API. If you already have your API hosted on Swagger, it is probably the best idea to directly import your JSON into KushoAI, which then utilizes an internal parser to obtain all information about your API and all endpoints as listed in your JSON. In addition KushoAI also provides you an option to select only those endpoints which you want to test. What lies next is to review the Endpoint URL and you are good to go. Just click Generate and site back to relax while KushoAI does all the work for you. A visual representation of how this works is shown below :

opt-2-1
opt-2-2
opt-2-3

c) Import from Postman Collections

One of my favorite features is the ability to import from Postman Collections, largely due to my extensive use of Postman. Previously, I would manually input the endpoint with the necessary methods and parameters. However, what I really wanted was to integrate these API calls directly into my tests, which is how I discovered KushoAI.

Here’s how simple it is:

  1. Export your Postman Collection as a JSON file.
  2. Upload the JSON file to KushoAI.
  3. Just like when importing OpenAPI specs, select the required parameters for which you need to generate tests.
  4. If you have any optional parameters like auth tokens, requests etc, then enter the details in the next popup.
  5. Click "Generate," then sit back, relax, and let KushoAI work its magic.

opt-3-1
opt-3-2
opt-3-3
opt-3-4

d) Import using cURL command

KushoAI also provides you an option to import the curl commands and directly create tests for you. A simple example of real world applicable cRUL command for which tests were created is given below.

curl -v -X POST \
    -F 'hostname=docker' \
    -F 'modelid=5000000002' \
    -F 'sitegroupid=1' \
    -F 'siteid=772' \
    -F 'sitename=Niwot Ridge Forest/LTER NWT1 (US-NR1)' \
    -F 'pft[]=temperate.coniferous' \
    -F 'start=2004/01/01' \
    -F 'end=2004/12/31' \
    -F 'input_met=5000000005' \
    -F 'email=' \
    -F 'notes=' \
    'http://pecan.localhost/pecan/04-runpecan.php'
Enter fullscreen mode Exit fullscreen mode

KushoAI Workbench and API Information

KushoAI makes accessing and managing API information incredibly simple, providing insights into data such as filters, counts, and detailed API information. Once KushoAI has processed your API details, it typically takes no more than a couple of minutes to generate fully functional test suites for your API collection, ready for execution.

But what if you need to fine-tune the generated test cases to fit specific scenarios? No worries—KushoAI has you covered with an easy-to-use interface that allows you to modify request details and tailor the tests to your exact needs.

In addition to customization, KushoAI offers parallel computation and API calls, a feature that significantly reduces latency and boosts efficiency. This is one of the most impressive features KushoAI brings to the table, allowing you to test APIs faster and with greater precision.

However, when I say "one of the most impressive," I truly mean it, because KushoAI offers even more. You can automatically generate AI Assertions for each API request using Generative AI, which, in my opinion, is the standout feature of the platform. You can even integrate custom assertions, a feature that I haven’t seen work as quickly or effectively anywhere else.

Below are some examples of requests I processed using KushoAI, demonstrating how its services work. For this, I used a custom endpoint for the WeatherAPI to showcase KushoAI’s capabilities. The ability to easily integrate with your own custom assertions is a game-changer, offering unmatched flexibility and speed. Below are some assertions which were automatically generated using KushoAI's inbuilt Generative AI :

expect(response.response.location.name, "name should exist").to.exist;
expect(response.response.location.name, "name should be a string").to.be.a('string');
expect(response.response.location.region, "region should exist").to.exist;
expect(response.response.forecast.forecastday[0].hour[0].gust_kph, "gust_kph should be a number").to.be.a('number');
expect(response.response.forecast.forecastday[0].hour[0].uv, "uv should exist").to.exist;
expect(response.response.forecast.forecastday[0].hour[0].uv, "uv should be a number").to.be.a('number');
expect(response.statusCode, "statusCode should exist").to.exist;
expect(response.statusCode, "statusCode should be a number").to.be.a('number');
Enter fullscreen mode Exit fullscreen mode

WB-1
WB-2

Workspaces and Collaboration

KushoAI offers a robust Workspaces feature that enables seamless collaboration among users, allowing teams to work together efficiently on API collections. This feature is especially useful for larger teams or projects where multiple individuals need to contribute to the same API testing suite, fostering real-time collaboration and making the development process smoother.

If you're familiar with GitHub, you'll find this functionality quite similar. Just as GitHub allows multiple developers to collaborate on code, KushoAI enables teams to work simultaneously on API collections, share test cases, and address the same issues without stepping on each other’s toes.

This Spectacular feature helps teams stay in sync, reducing bottlenecks and improving productivity. By centralizing the workspace and offering easy access to shared projects, KushoAI streamlines the API testing workflow, making it easier for users to track changes, provide feedback, and enhance the overall quality of their API services.

Whether you're working with a small team or managing a large project with many contributors, KushoAI ensures that collaboration is as efficient and frictionless as possible. With real-time updates and shared access to API collections, it takes teamwork in API testing to a whole new level. You can also manage your API Keys for further integrations and CI automation (which we will discuss a bit later) along with Environment Variables to store your secrets.

KushoAI's Workbench provides a more sophisticated and user-friendly interface than Postman's, allowing for greater flexibility and control during API testing. While Postman is well-known for its simplicity and ease of use, KushoAI goes above and beyond with capabilities such as custom test case generation, real-time modification of API requests, and parallel test execution, all of which greatly speed up the testing process. KushoAI's Workbench is built with Generative AI at its heart, allowing it to automatically develop extensive test cases across numerous scenarios—something Postman often restricts to simple checks like response status and time. Furthermore, KushoAI delivers extensive insights into the data coming via your APIs, allowing users to select and analyse results more accurately.

Integration in your CI/CD Pipelines

KushoAI offers seamless integration with your CI/CD pipelines, providing automated, real-time test generation and execution, without the need for any manual intervention. This integration ensures that every time a new commit is pushed or a change is made, KushoAI automatically runs tests to validate your API’s functionality, performance, and security.

Currently available as part of KushoAI’s Enterprise plan, this feature is designed for organizations that need continuous testing at scale. By incorporating KushoAI into your CI/CD workflow, you can ensure that every API update is thoroughly tested, reducing the likelihood of bugs and security vulnerabilities slipping into production.

KushoAI also supports GitHub Actions, making it easy to integrate API testing directly into your GitHub-based workflows. This allows your development and testing teams to catch issues early in the development process, improving overall efficiency and reducing the time spent on manual testing.

Automating your API testing as part of a CI/CD pipeline not only enhances testing performance but also significantly boosts security. Every change is automatically validated, meaning you can deploy confidently knowing your APIs have been tested at every stage of the development lifecycle. This eliminates potential security risks caused by human error, offering a reliable safeguard against bugs and vulnerabilities.

For more detailed information or to discuss how CI/CD integration can benefit your organization, the KushoAI team is available to provide consultation and support. Below is a visual representation of how the integration works within a typical pipeline:

Test Reports.

Once your test suites are completed, KushoAI will notify you when the testing process is complete, allowing you to focus on other things without having to manually monitor the tests. This is especially valuable for teams with many priorities, since it guarantees that your time is used efficiently while KushoAI does the testing.

In addition to alerts, KushoAI offers a real-time view of your test suite's generation status. You can simply follow the progress of your tests via the generation status page on the home tab, which keeps you updated on every stage of the process. This real-time visibility is critical for ensuring that no tests are left unfinished, providing you assurance that all APIs have been completely tested.

Once testing is completed, KushoAI provides export choices for test suites and results. You may export these reports in 'HTML' format, which provides a concise and well-organised overview of your test findings. These reports not only capture current tests, but they may also be saved for future reference, making it easier to follow progress or regression issues over time.

This functionality is extremely useful for companies trying to continually enhance their API speed. Reviewing these extensive reports allows you to discover possible issues, make appropriate changes, and retain a historical record of how your APIs have changed. KushoAI's reporting tools guarantee you always have access to actionable insights.

t-r-1

t-r-2

Image showing how data is exported in html format for further utilization

KushoAI's end-to-end testing (beta) features

Through the use of KushoAI's End-to-End (E2E) testing functionality, developers may replicate real-world processes by sequentially testing numerous API interactions to make sure they perform as intended. Engineers may use this functionality to cover complicated situations involving several endpoints, offering insights into the behaviour of your APIs in production environments. E2E testing offers many features, some of the most prominent features are:

  1. API Selection for Testing: - Users can add new APIs or pick existing ones to the test suite. For example, selecting "Weather Forecast API for Gorakhpur" as displayed in the image demonstrates that several endpoints and functions may be coupled to replicate a real-world scenario.

  2. Workflow Automation: - The "Run" and "Save Workflow" buttons enable users to develop, run, and store end-to-end tests for reuse. You may create processes that test APIs in the same order in which a real user would interact with them.

  3. Collaboration and Customization: - The Workspace feature in the top-right corner helps teams cooperate on processes and maintain test environments efficiently.

  4. User-Friendly Interface: The UI is intended to provide straightforward API administration, allowing users to quickly switch between adding new APIs and selecting pre-configured ones for testing. It also supports parallel API execution and real-time scenario validation.

e2e

Images demonstrating UX flow of KushoAI's E2E testing (BETA)

KushoAI vs. Postman: Generative Tests

One might wonder, why choose KushoAI when Postman also offers generative tests? The answer is simple: KushoAI offers a far more comprehensive and intelligent testing experience. While Postman generates tests based on limited factors like response time and status codes, KushoAI generates tests across all possible testing scenarios, regardless of the specifics of your collection.

This is a game-changer. Postman often restricts the scope of its generated tests, relying heavily on predefined conditions. In contrast, KushoAI takes a more robust approach, ensuring that your API is tested under a broader array of conditions, including edge cases and performance bottlenecks that Postman might overlook.

To illustrate this, I ran simulations on my localhost backend server to check user data and responses similar to the earlier example using the Weather API. The results clearly show that KushoAI's generative testing framework not only provided more test cases but also delved deeper into potential failure points and error scenarios that Postman's approach missed entirely. KushoAI's ability to create comprehensive tests across all layers of functionality, from endpoint stability to data integrity, demonstrates its superior coverage and reliability.

Moreover, KushoAI's Generative AI is tailored to identify nuanced issues in your APIs, offering intelligent assertions and custom test cases that align with your specific needs—something Postman lacks. With KushoAI, you're not just testing based on surface-level metrics; you're validating the entire API lifecycle, from security vulnerabilities to real-world stress testing.

In short, KushoAI outperforms other generative testing solutions like Postman by ensuring that every aspect of your API is rigorously tested, offering deeper insights, greater flexibility, and more reliable results. The proof is in the tests generated via Postman and KushoAI which showcases how KushoAI’s advanced testing engine gives you a level of coverage that sets it apart from the competition.

postman-img

kusho-img

While KushoAI decides to test scenarios comprising of data conditions, Postman decided to test scenarios with Error codes and Body Content.

Conclusion

Apart from being an automated testing tool, KushoAI is a robust and far more superior platform than others that simplifies the entire process of developing and testing APIs. It removes the tedious effort associated with API testing by employing cutting-edge AI technology, allowing developers to focus on what is actually important: creativity. From its seamless CI/CD integrations to collaborative workspaces and custom test generation, It also provides everything needed to enhance productivity, reduce errors, and accelerate delivery. Whether you’re a small team or a large enterprise, KushoAI’s features ensure that your APIs are tested thoroughly, securely, and efficiently. With KushoAI by your side, API testing becomes not just easier, but smarter.

đź’– đź’Ş đź™… đźš©
devrx
Abhinav Pandey

Posted on October 14, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

API Testing Made Effortless : KushoAI
testing API Testing Made Effortless : KushoAI

October 14, 2024