{"id":669,"date":"2019-11-18T12:31:23","date_gmt":"2019-11-18T12:31:23","guid":{"rendered":"https:\/\/www.dhruvsoft.com\/blog\/?p=669"},"modified":"2024-07-26T09:41:27","modified_gmt":"2024-07-26T09:41:27","slug":"runscope-primer-using-runscope-for-api-testing","status":"publish","type":"post","link":"https:\/\/www.dhruvsoft.com\/blog\/runscope-primer-using-runscope-for-api-testing\/","title":{"rendered":"Runscope Primer &#8211; Using Runscope for API testing"},"content":{"rendered":"\n<p>Runscope\u00a0is one of the popular solutions for API performance testing, monitoring and debugging. Runscope helps in creating, managing and executing functional API tests and monitors.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2019\/11\/Runscope-Primer-Using-Runscope-for-API-testing-1024x576.png\" alt=\"Runscope Primer - Using Runscope for API testing\" class=\"wp-image-675\" srcset=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2019\/11\/Runscope-Primer-Using-Runscope-for-API-testing-1024x576.png 1024w, https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2019\/11\/Runscope-Primer-Using-Runscope-for-API-testing-300x169.png 300w, https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2019\/11\/Runscope-Primer-Using-Runscope-for-API-testing-768x432.png 768w, https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2019\/11\/Runscope-Primer-Using-Runscope-for-API-testing.png 1280w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n\n<!--more-->\n\n\n\n<p>The most common use case where Runscope is used is to test the API. You can execute one or more HTTP requests sequentially&nbsp;to evaluate the performance, up time and correctness.&nbsp;<\/p>\n\n\n\n<p>Users can define Assertions for each request; a test passes if all the assertion pass, a test fails if any of the assertion fail. Also users can schedule test can be used for ongoing monitoring.<\/p>\n\n\n\n<p>One can define an assertion in a way which should have source and target values. Users can compare the extracted data with the target value.<\/p>\n\n\n\n<p>User can create a test case as shown in below image<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2019\/11\/create-a-test-case.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"384\" src=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2019\/11\/create-a-test-case-1024x384.jpg\" alt=\"Using Run-scope for API testing create a test case\" class=\"wp-image-670\" srcset=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2019\/11\/create-a-test-case-1024x384.jpg 1024w, https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2019\/11\/create-a-test-case-300x112.jpg 300w, https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2019\/11\/create-a-test-case-768x288.jpg 768w, https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2019\/11\/create-a-test-case.jpg 1027w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div>\n\n\n\n<p>After creating a test you will see a request step like below<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><a href=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2019\/11\/After-creating-a-test-you-will-see-a-request-step.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2019\/11\/After-creating-a-test-you-will-see-a-request-step.jpg\" alt=\"After creating a test you will see a request step\" class=\"wp-image-671\" width=\"840\" height=\"371\" srcset=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2019\/11\/After-creating-a-test-you-will-see-a-request-step.jpg 927w, https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2019\/11\/After-creating-a-test-you-will-see-a-request-step-300x133.jpg 300w, https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2019\/11\/After-creating-a-test-you-will-see-a-request-step-768x340.jpg 768w\" sizes=\"auto, (max-width: 840px) 100vw, 840px\" \/><\/a><\/figure><\/div>\n\n\n\n<p>From here, you can give Endpoint url to test with request types either Get, Post, Put etc;<\/p>\n\n\n\n<p>You can define assertion by clicking on Assertion tab which has to compare target value with the requested value<\/p>\n\n\n\n<p>If the request passes we get a status code of 200 for that request. If the request is bad we will get the status code of 400.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Variables<\/h5>\n\n\n\n<p>You can define a variable which can be used in a subsequent request and also for storing a value. We can define a variable in two ways<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Local variable<\/li><li>Environment&nbsp; variable<\/li><\/ol>\n\n\n\n<p>Local variable will be used for only one request in a defined place and on the other hand, environment variable is used for all the request that can define in a Test i.e, we can inherit and use in another request<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Pre request script<\/h5>\n\n\n\n<p>From here you can add a script that can be used to run initially. For example, if you want to clear a header value which is coming from environment variables before executing a request<\/p>\n\n\n\n<p>delete request.headers[\u00e2\u20ac\u0153your_header\u00e2\u20ac&#x2122;];<\/p>\n\n\n\n<p>This line of script is used to delete a header for that request.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Post response script<\/h5>\n\n\n\n<p>You can add a script which should be run after the request executed. For example, if you want to store an Id of record that can use in another request of a test.<\/p>\n\n\n\n<p>Headers, Body, and Authentication can be added in a single request<\/p>\n\n\n\n<p>You can create a condition before executing a request. If the condition passes, then that particular request can execute<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"108\" src=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2019\/11\/create-a-condition-before-executing-a-request-1024x108.jpg\" alt=\"create a condition before executing a request\" class=\"wp-image-672\" srcset=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2019\/11\/create-a-condition-before-executing-a-request-1024x108.jpg 1024w, https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2019\/11\/create-a-condition-before-executing-a-request-300x32.jpg 300w, https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2019\/11\/create-a-condition-before-executing-a-request-768x81.jpg 768w, https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2019\/11\/create-a-condition-before-executing-a-request.jpg 1050w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n\n<p>You can use one request as subtest to another request by clicking on add step<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"112\" src=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2019\/11\/use-one-request-as-subtest-to-another-request-by-clicking-on-add-step-1024x112.jpg\" alt=\"use one request as subtest to another request by clicking on add step\" class=\"wp-image-673\" srcset=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2019\/11\/use-one-request-as-subtest-to-another-request-by-clicking-on-add-step-1024x112.jpg 1024w, https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2019\/11\/use-one-request-as-subtest-to-another-request-by-clicking-on-add-step-300x33.jpg 300w, https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2019\/11\/use-one-request-as-subtest-to-another-request-by-clicking-on-add-step-768x84.jpg 768w, https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2019\/11\/use-one-request-as-subtest-to-another-request-by-clicking-on-add-step.jpg 1033w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h5 class=\"wp-block-heading\">Run your test<\/h5>\n\n\n\n<p>Click&nbsp;<strong>Save &amp; Run<\/strong>&nbsp;to start a new test run. The request will be executed and upon completion, each assertion will be checked. If everything checks out, you should see that the test run&nbsp;<strong>Passed<\/strong>. Select the test run from the results list to view the full HTTP request, response, and test output.<\/p>\n\n\n\n<p>Refer below image to know the details<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"607\" height=\"380\" src=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2019\/11\/Select-the-test-run-from-the-results.jpg\" alt=\"Select the test run from the results\" class=\"wp-image-674\" srcset=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2019\/11\/Select-the-test-run-from-the-results.jpg 607w, https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2019\/11\/Select-the-test-run-from-the-results-300x188.jpg 300w\" sizes=\"auto, (max-width: 607px) 100vw, 607px\" \/><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Runscope\u00a0is one of the popular solutions for API performance testing, monitoring and debugging. Runscope helps in creating, managing and executing functional API tests and monitors.<\/p>\n","protected":false},"author":21,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[],"class_list":["post-669","post","type-post","status-publish","format-standard","hentry","category-salesforce-com-crm","entry"],"_links":{"self":[{"href":"https:\/\/www.dhruvsoft.com\/blog\/wp-json\/wp\/v2\/posts\/669","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dhruvsoft.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dhruvsoft.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dhruvsoft.com\/blog\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dhruvsoft.com\/blog\/wp-json\/wp\/v2\/comments?post=669"}],"version-history":[{"count":0,"href":"https:\/\/www.dhruvsoft.com\/blog\/wp-json\/wp\/v2\/posts\/669\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dhruvsoft.com\/blog\/wp-json\/wp\/v2\/media?parent=669"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dhruvsoft.com\/blog\/wp-json\/wp\/v2\/categories?post=669"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dhruvsoft.com\/blog\/wp-json\/wp\/v2\/tags?post=669"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}