#
Running tests
Once you're done with creating a test suite for your API, you can run the generated tests to see if your API is working as expected from the Test Suite Details page.
This is how running tests from KushoAI webapp works:
- You can run tests using one these options - run single test, run all, run a subset of tests
- When you run a test, KushoAI makes an API call using the API payload for that test. You can view the API payload in "Requests" tab of Test Details sections which can be opened by clicking on "Details" button for a test.
- This API call is routed via a KushoAI's Chrome Extension to bypass browser's CORS restrictions. More about this
below . - Note that API calls for tests go from your browser via KushoAI's Chrome Extension. So you will be able to run tests even if your backend is running on localhost or behind a VPN.
- Once the API call returns, the response is displayed in "Response" tab in Test Details section.
- If you have defined assertions for the test, these assertions will be validated against the API response. You can view assertion results under the "Assertion Results" tab in Test Details section. Along with that, you'll see a passed/failed status under "Assertions" column.
- If you have not defined any assertions, you'll see blank or "N/A" under "Assertions" column.
Apart from running tests from the Test Suite Details page, you also have the option to add test suites to a group and run an entire group in one go or run tests from your CI/CD platform.
#
Why do I need to install an extension to run tests?
KushoAI needs to make API calls to your test setup (which could be localhost, behind a VPN or running on cloud) from the browser to test your APIs. Now the problem with doing this is that modern browsers generally block all API calls going to different origins that the one from which the page was loaded due to CORS restrictions. For example, KushoAI's webapp is loaded from kusho.ai
domain, but your test setup might be hosted on qa.foobar.com
domain. Because the origin of webpage (kusho.ai
) will always be different from the domain on which tests will be executed, making an API call directly from the webapp will result in it getting blocked
To bypass this restriction, we built a Chrome extension whose sole purpose is acting like a proxy for API calls. So when you run tests, the KushoAI webapp tells the Chrome extension to make the API call (which is not blocked by browser CORS restrictions) and send the response back to the webapp.
KushoAI's Chrome extension is active only when the domain of the web page is kusho.ai
. You can verify this by looking at the extension's manifest.yml (link). So you don't need to worry about the extension intercepting API calls from any other web pages. You can also download the extension as a CRX file and go over it's code to verify that all it does is what we've mentioned here. Here a short tutorial on how to do that (link).
And if you're still unsure about it, head to our Slack workspace and ping us on the #support channel. We'll be more than happy to hop on a call to explain how it works.