<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Creyn &#187; tests</title>
	<atom:link href="http://blog.creyn.pl/tag/tests/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.creyn.pl</link>
	<description>Programmer&#039;s notes</description>
	<lastBuildDate>Mon, 22 Aug 2016 07:00:21 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.0.38</generator>
	<item>
		<title>Postman: framework for testing API</title>
		<link>http://blog.creyn.pl/2016/06/27/postman-framework-for-testing-api/</link>
		<comments>http://blog.creyn.pl/2016/06/27/postman-framework-for-testing-api/#comments</comments>
		<pubDate>Mon, 27 Jun 2016 06:00:51 +0000</pubDate>
		<dc:creator><![CDATA[creyn]]></dc:creator>
				<category><![CDATA[Programmer's notes]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Postman]]></category>
		<category><![CDATA[tests]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://blog.creyn.pl/?p=531</guid>
		<description><![CDATA[Few times in the past I had to do some testing on my APIs. I needed very simple way to easily call different HTTP method like POST or PUT with some specific custom HTTP Headers. I have used a few tools for this but all of them seem to have some minor or major issues...]]></description>
				<content:encoded><![CDATA[<p style="text-align: justify;">Few times in the past I had to do some testing on my APIs. I needed very simple way to easily call different HTTP method like POST or PUT with some specific custom HTTP Headers. I have used a few tools for this but all of them seem to have some minor or major issues that I don&#8217;t like. For a while I thought that the <strong>&#8220;<a href="https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo" target="_blank">Advanced Rest Client</a>&#8220;</strong> will be a winner. And everybody at my company were using it. But then it changed in a way that I needed something different. And that is how I found <strong>&#8220;Postman&#8221;</strong>.</p>
<p style="text-align: justify;">It is an extension for Chrome browser. Which is good when you don&#8217;t have permissions to install new software on production, but you can launch some browser extensions ;) The installation is very simple as every extension for Chrome. Just look for the &#8220;<strong>Postman</strong>&#8221; in the Chrome extension manager (<a href="https://chrome.google.com/webstore/" target="_blank">https://chrome.google.com/webstore/</a>) and then click <strong>&#8220;Add to Chrome&#8221;</strong>. It then will show in the Chrome Apps section (<strong>&#8220;chrome://apps/&#8221;</strong>) .</p>
<p style="text-align: justify;"><img class="aligncenter size-full wp-image-533" src="http://blog.creyn.pl/wp-content/uploads/2016/06/p_1.png" alt="_p_1" width="905" height="91" /></p>
<p style="text-align: justify;">After the first launch, you will have an option to create the <strong>&#8220;Postman&#8221;</strong> account. You can skip this step, but having the account will let you sync your test requests with other computers and even colaborate on them with your colleagues. I&#8217;ve choosen the <strong>&#8220;Sign Up with Google&#8221;</strong> option. Then, upon login, Google send me the confirmation SMS with a unique code and polish characters encoding error (so hey, encoding is hard, it happens to everybody ;)). The <strong>&#8220;Postman&#8221;</strong> requirements for my account are very simple and look ok for me, so I allowed it to do so.</p>
<p style="text-align: justify;"><img class="aligncenter size-full wp-image-534" src="http://blog.creyn.pl/wp-content/uploads/2016/06/p_2.png" alt="_p_2" width="625" height="552" /></p>
<p style="text-align: justify;"><img class="aligncenter size-full wp-image-535" src="http://blog.creyn.pl/wp-content/uploads/2016/06/p_3.png" alt="_p_3" width="452" height="214" /></p>
<p style="text-align: justify;"><strong>&#8220;Postman&#8221;</strong> started and I am connected to my account. In the main window, the upper part is the <strong>&#8220;Request&#8221;</strong> section. You can specify all parameters that you want to send, including headers.</p>
<p style="text-align: justify;"><img class="aligncenter size-full wp-image-536" src="http://blog.creyn.pl/wp-content/uploads/2016/06/p_4.png" alt="_p_4" width="1264" height="614" /></p>
<p style="text-align: justify;">So let&#8217;s try if it works. In the <strong>&#8220;Enter request URL&#8221;</strong> please enter the <strong>&#8220;<a href="http://blog.creyn.pl" target="_blank">http://blog.creyn.pl</a>&#8220;</strong> and then click on <strong>&#8220;Send&#8221;</strong>. The bottom part of the screen is the <strong>&#8220;Response&#8221;</strong> section. There you can find: response time, response status, response body, cookies and headers. You can see that my blog homepage responded with success.</p>
<p style="text-align: justify;">I really recommend you to save your requests to a <strong>&#8220;Collection&#8221;</strong>, because even if all requests are saved into the <strong>&#8220;History&#8221;</strong> section (on the left), the collection will be usefull for us in the future. After clicking the <strong>&#8220;Save&#8221;</strong> button you will have to create a name for this request. It is also usefull to add some grouping to your requests. So I created a new one called <strong>&#8220;CreynBlog&#8221;</strong>. On the left part there is a <strong>&#8220;History / Collections&#8221;</strong> section and you can see the new request we just added and also some predefined <strong>&#8220;Postman Echo&#8221;</strong> collection. In this default collection you can find some very usefull examples of what can be done with the <strong>&#8220;Postman&#8221;</strong> tests, as this is actually a very nice test framework for your APIs.</p>
<p style="text-align: justify;"><img class="aligncenter size-full wp-image-537" src="http://blog.creyn.pl/wp-content/uploads/2016/06/p_5.png" alt="_p_5" width="300" height="544" /><br />
So let&#8217;s pick the <strong>&#8220;Postman Echo &gt; Cookies &gt; Set Cookies&#8221;</strong> test request. This is a <strong>&#8220;GET&#8221;</strong> request to the <strong>&#8220;https://echo.getpostman.com/cookies/set?foo1=bar1&amp;foo2=bar&#8221;</strong> URL. The response from the server set cookies with the names specified in the URL. But what is interesting is the <strong>&#8220;Tests&#8221;</strong> tab in the <strong>&#8220;Request&#8221;</strong> section. You can find there a test case written in JavaScript. Tests are defined in an array called &#8220;tests&#8221; and the names are later shown on the <strong>&#8220;Tests&#8221;</strong> tab in the <strong>&#8220;Response&#8221;</strong> section. There are 4 tests defined and all passed successfully. This will be very usefull in testing our own APIs and I will show you later what we can do with it. And as it is JavaScript we can do a lot.</p>
<p style="text-align: justify;"><img class="aligncenter size-full wp-image-538" src="http://blog.creyn.pl/wp-content/uploads/2016/06/p_6.png" alt="_p_6" width="950" height="529" /></p>
<p style="text-align: justify;">I said that having test requests saved in the <strong>&#8220;Collection&#8221;</strong> will be usefull. Now, when we have a collectoin full of test cases we can run them easilly. For that we will use the <strong>&#8220;Runner&#8221;</strong> which is located at the top left part of the window. It will start a new window and you can pick your test collections to run. I will go into details in the future.</p>
<p style="text-align: justify;">C.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.creyn.pl/2016/06/27/postman-framework-for-testing-api/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
