{"id":25,"date":"2017-07-10T14:33:00","date_gmt":"2017-07-10T19:33:00","guid":{"rendered":""},"modified":"2023-07-26T12:53:30","modified_gmt":"2023-07-26T17:53:30","slug":"testing-postman-and-swagger-as-additions-to-your-tests","status":"publish","type":"post","link":"https:\/\/www.chrystalsander.com\/blog\/?p=25","title":{"rendered":"Testing:  Postman and Swagger As Additions to Your Tests"},"content":{"rendered":"<p><span style=\"font-family: inherit;\">Often I need to queue up some unit tests on-the-fly. I recently came across the following helpers:<\/span><\/p>\n<div>\n<\/div>\n<div style=\"margin-bottom: .0001pt; margin: 0in;\">\n<b><span style=\"font-size: 11pt;\"><span style=\"font-family: inherit;\">1. &nbsp;CREATE POSTMAN API TESTS FROM<br \/>\nSWAGGER<o:p><\/o:p><\/span><\/span><\/b><\/div>\n<div style=\"margin-bottom: .0001pt; margin: 0in;\">\n<b><span style=\"font-size: 11pt;\"><span style=\"font-family: inherit;\"><br \/><\/span><\/span><\/b><\/div>\n<div style=\"margin-bottom: .0001pt; margin: 0in;\">\n<span style=\"color: #333333; font-size: 13.3333px;\"><span style=\"font-family: inherit;\">In case anyone else did not know, it is now an option to take the swagger document from your WebAPI, import it into Postman and, voila, test cases for controllers created. &nbsp;&nbsp;<\/span><\/span><\/div>\n<div style=\"margin-bottom: .0001pt; margin: 0in;\">\n<b><span style=\"font-size: 11pt;\"><span style=\"font-family: inherit;\"><br \/><\/span><\/span><\/b><\/div>\n<div style=\"margin-bottom: .0001pt; margin: 0in;\">\n<span style=\"font-size: 11pt;\"><span style=\"font-family: inherit;\"><a href=\"https:\/\/www.getpostman.com\/docs\/postman\/collections\/data_formats\" target=\"_blank\" rel=\"noopener\">https:\/\/www.getpostman.com\/docs\/postman\/collections\/data_formats<\/a><o:p><\/o:p><\/span><\/span><\/div>\n<div style=\"margin-bottom: .0001pt; margin: 0in;\">\n<\/div>\n<div style=\"margin-left: 27.0pt; mso-list: l0 level1 lfo1; tab-stops: list .5in; text-indent: -.25in; vertical-align: middle;\">\n<!--[if !supportLists]--><span style=\"font-family: inherit;\">1.<span style=\"font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><!--[endif]-->Create swagger.json from API<o:p><\/o:p><\/span><\/div>\n<div style=\"margin-left: .75in; mso-list: l0 level2 lfo2; tab-stops: list 1.0in; text-indent: -.25in; vertical-align: middle;\">\n<!--[if !supportLists]--><span style=\"font-family: inherit;\">a.<span style=\"font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><!--[endif]-->ie, <a href=\"http:\/\/10.157.135.155:8080\/swagger\/docs\/v1\">http:\/\/10.157.135.155:8080\/swagger\/docs\/v1<\/a><o:p><\/o:p><\/span><\/div>\n<div style=\"margin-left: 27.0pt; mso-list: l0 level1 lfo2; tab-stops: list .5in; text-indent: -.25in; vertical-align: middle;\">\n<!--[if !supportLists]--><span style=\"font-family: inherit;\">2.<span style=\"font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><!--[endif]-->Open Postman<o:p><\/o:p><\/span><\/div>\n<div style=\"margin-left: 27.0pt; mso-list: l0 level1 lfo2; tab-stops: list .5in; text-indent: -.25in; vertical-align: middle;\">\n<!--[if !supportLists]--><span style=\"font-family: inherit;\">3.<span style=\"font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><!--[endif]-->Navigate to &#8220;Import&#8221; button<o:p><\/o:p><\/span><\/div>\n<p><\/p>\n<div style=\"margin-left: 27.0pt; mso-list: l0 level1 lfo2; tab-stops: list .5in; text-indent: -.25in; vertical-align: middle;\">\n<!--[if !supportLists]--><span style=\"font-family: inherit;\">4.<span style=\"font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><!--[endif]-->Open swagger.json file (or paste, etc)<o:p><\/o:p><\/span><\/div>\n<div style=\"margin-left: 27.0pt; mso-list: l0 level1 lfo2; tab-stops: list .5in; text-indent: -.25in; vertical-align: middle;\">\n<span style=\"font-family: inherit;\"><br \/><\/span><\/div>\n<div style=\"margin: 0in 0in 0.0001pt;\">\n<b><span style=\"font-size: 11pt;\"><span style=\"font-family: inherit;\">2. &nbsp;RUN POSTMAN TESTS FROM VISUAL STUDIO<o:p><\/o:p><\/span><\/span><\/b><\/div>\n<div style=\"margin: 0in 0in 0.0001pt;\">\n<b><span style=\"font-size: 11pt;\"><span style=\"font-family: inherit;\"><br \/><\/span><\/span><\/b><\/div>\n<div style=\"margin: 0in 0in 0.0001pt;\">\n<span style=\"font-family: inherit;\"><span style=\"background-color: white; color: #333333; font-size: 14px;\">Postman Runner for VSCode allows you to run&nbsp;<\/span><a href=\"https:\/\/www.getpostman.com\/\" rel=\"noreferrer noopener\" style=\"background-color: white; box-sizing: border-box; color: #0078d7; cursor: pointer; font-size: 14px; text-decoration-line: none;\">Postman<\/a><span style=\"background-color: white; color: #333333; font-size: 14px;\">&nbsp;tests from your VSCode. It analyze the workspace folder and locate&nbsp;<\/span><em style=\"background-color: white; box-sizing: border-box; color: #333333; font-size: 14px;\">collection<\/em><span style=\"background-color: white; color: #333333; font-size: 14px;\">&nbsp;and&nbsp;<\/span><em style=\"background-color: white; box-sizing: border-box; color: #333333; font-size: 14px;\">environment<\/em><span style=\"background-color: white; color: #333333; font-size: 14px;\">&nbsp;files.<\/span><\/span><\/div>\n<div style=\"height: 0px;\">\n<\/div>\n<ul style=\"background-color: white; box-sizing: border-box; color: #333333; font-size: 14px;\">\n<li style=\"box-sizing: border-box;\"><span style=\"font-family: inherit;\">Export your Postman&nbsp;<em style=\"box-sizing: border-box;\">collections<\/em>&nbsp;and&nbsp;<em style=\"box-sizing: border-box;\">environments<\/em>&nbsp;in a folder (or subfolders) and open it with VSCode.<\/span><\/li>\n<\/ul>\n<ul style=\"background-color: white; box-sizing: border-box; color: #333333; font-size: 14px;\">\n<li style=\"box-sizing: border-box;\"><span style=\"font-family: inherit;\">Open the&nbsp;<code style=\"background-color: rgba(0, 0, 0, 0.04); border-radius: 3px; box-sizing: border-box; margin: 0px; padding: 0.2em 0px;\">Command Palette<\/code><\/span><\/li>\n<\/ul>\n<ul style=\"background-color: white; box-sizing: border-box; color: #333333; font-size: 14px;\">\n<li style=\"box-sizing: border-box;\"><span style=\"font-family: inherit;\">Choose&nbsp;<code style=\"background-color: rgba(0, 0, 0, 0.04); border-radius: 3px; box-sizing: border-box; margin: 0px; padding: 0.2em 0px;\">Postman: Run &gt; Question Mode<\/code>&nbsp;(&nbsp;<code style=\"background-color: rgba(0, 0, 0, 0.04); border-radius: 3px; box-sizing: border-box; margin: 0px; padding: 0.2em 0px;\">Ctrl+Q<\/code>&nbsp;,&nbsp;<code style=\"background-color: rgba(0, 0, 0, 0.04); border-radius: 3px; box-sizing: border-box; margin: 0px; padding: 0.2em 0px;\">Cmd+R<\/code>&nbsp;)<\/span><\/li>\n<\/ul>\n<p><span style=\"font-family: inherit;\"><span style=\"color: #333333;\"><span style=\"font-size: 14px;\"><a href=\"https:\/\/www.blogger.com\/goog_1779991130\"><br \/><\/a><\/span><\/span><span style=\"color: #333333;\"><span style=\"font-size: 14px;\"><a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=eridem.vscode-postman\" target=\"_blank\" rel=\"noopener\">https:\/\/marketplace.visualstudio.com\/items?itemName=eridem.vscode-postman<\/a><\/span><\/span><span style=\"color: #333333;\"><span style=\"font-size: 14px;\"><br \/><\/span><\/span><b><span style=\"font-size: 11pt;\"><br \/><\/span><\/b><\/span><\/p>\n<div style=\"margin: 0in 0in 0.0001pt;\">\n<span style=\"background-color: white; color: #333333; font-size: 14px;\"><span style=\"font-family: inherit;\"><br \/><\/span><\/span><\/div>\n<div style=\"margin: 0in 0in 0.0001pt;\">\n<span style=\"background-color: white; color: #333333; font-family: , &quot;helvetica neue&quot; , &quot;helvetica&quot; , &quot;arial&quot; , &quot;verdana&quot;; font-size: 14px;\"><br \/><\/span><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Often I need to queue up some unit tests on-the-fly. I recently came across the following helpers: 1. &nbsp;CREATE POSTMAN API TESTS FROM SWAGGER In case anyone else did not know, it is now an option to take the swagger document from your WebAPI, import it into Postman and, voila, test cases for controllers created. &hellip; <a href=\"https:\/\/www.chrystalsander.com\/blog\/?p=25\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Testing:  Postman and Swagger As Additions to Your Tests&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,15],"tags":[76,77],"_links":{"self":[{"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/25"}],"collection":[{"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=25"}],"version-history":[{"count":1,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/25\/revisions"}],"predecessor-version":[{"id":158,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/25\/revisions\/158"}],"wp:attachment":[{"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=25"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=25"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.chrystalsander.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=25"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}