<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Murillo Welsi on Medium]]></title>
        <description><![CDATA[Stories by Murillo Welsi on Medium]]></description>
        <link>https://medium.com/@murillo-welsi?source=rss-7ee1209d126c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*cfOrwgjGLbGk6C30trc0dg.png</url>
            <title>Stories by Murillo Welsi on Medium</title>
            <link>https://medium.com/@murillo-welsi?source=rss-7ee1209d126c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 09:55:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@murillo-welsi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How I Built and Published My First Claude Code Plugin]]></title>
            <link>https://murillo-welsi.medium.com/how-i-built-and-published-my-first-claude-code-plugin-f7a0642d66ad?source=rss-7ee1209d126c------2</link>
            <guid isPermaLink="false">https://medium.com/p/f7a0642d66ad</guid>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[marketplaces]]></category>
            <category><![CDATA[plugins]]></category>
            <dc:creator><![CDATA[Murillo Welsi]]></dc:creator>
            <pubDate>Tue, 03 Mar 2026 21:47:24 GMT</pubDate>
            <atom:updated>2026-03-03T21:47:24.294Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently, I’ve been studying and experimenting with <strong>Claude Code — </strong>and like most people, I started using it more like a chatbot. Ping-ponging questions back and forth, asking it to generate code, fix bugs, explain things. Useful, sure. But nothing I’d call a real workflow.</p><p>That changed last week. I had two talks at 25Friday, the company I work for, and that completely shifted how I was thinking about it.</p><p>I’m still learning. This post is my attempt to document what I’ve figured out so far.</p><h3>The Problem I Was Trying to Solve</h3><p>I’m a QA engineer. A big part of my job happens before a single test is written — reviewing user stories, spotting ambiguous acceptance criteria, identifying missing edge cases, flagging things that will become defects if nobody catches them now.</p><p>This work is repetitive and cognitive. The same checklist, the same questions, applied to every story that lands in the backlog. I thought: this is exactly the kind of thing Claude should be helping with.</p><p>So I started building a set of prompts. A deep story analysis based on <strong>ISTQB</strong> principles. Structured test case generation using <strong>Equivalence Partitioning</strong>, <strong>BVA</strong>, <strong>Decision Tables</strong>, <strong>State Transition</strong>, and <strong>Error Guessing</strong>. A risk matrix that scores each test case by Likelihood × Impact and gives you a recommended execution order.</p><p>After some time spent on it, I had something that actually can worked well. I called it manual-qa-toolkit (yes, I’m the worst in naming things).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/315/0*JYv33Uzdc4XtHn33.gif" /></figure><h3>How It Works</h3><p>The toolkit is built on a few premises that Claude Code supports natively — no code, no build step, just structured markdown files.</p><h3>CLAUDE.md — The Foundation</h3><p>Everything starts with CLAUDE.md. This is a file Claude Code reads automatically at the start of every session. It&#39;s how you give Claude persistent context about a project without repeating yourself every time.</p><p>In this toolkit, the CLAUDE.md loads a rules file that encodes the entire ISTQB framework as standing context — the seven testing principles, the risk framework, the test case format, the acceptance criteria quality checklist. Claude doesn&#39;t need to be reminded of any of it. It&#39;s always there.</p><h3>Rules</h3><p>Rules are conventions that apply to every task without being asked. Instead of writing “use the INVEST criteria” in every prompt, I define it once:</p><pre>## User Story Quality Checklist (INVEST)<br><br>- Independent - can be developed and tested without depending on another story<br>- Negotiable - details can be discussed, not set in stone<br>- Valuable - delivers value to user or business<br>- Estimable - small and clear enough to estimate<br>- Small - completable in one sprint<br>- Testable - acceptance criteria can be objectively verified</pre><p>Every skill, every command, every analysis inherits this. Rules are the DRY principle applied to prompts.</p><h3>Skills</h3><p>Skills are slash commands the user triggers explicitly. Each one is a markdown file with a YAML header and a structured prompt:</p><pre>---<br>name: analyse-story<br>description: Analyse a user story using ISTQB principles. Finds ambiguities, missing ACs, and testability issues.<br>---</pre><p>The toolkit has three:</p><ul><li>/analyse-story — INVEST check, AC review, missing scenarios, severity flags</li><li>/generate-test-cases — full test case table with coverage matrix</li><li>/assess-risk — risk matrix sorted by score, with a phased execution order</li></ul><p>Each skill has a defined output format — a markdown template that Claude fills in every run. Consistent input, consistent output.</p><h3>Agents</h3><p>Agents are the part I find most interesting. Unlike skills, they’re proactive — they fire automatically based on what happens in the conversation.</p><p>The story-analyser agent triggers the moment someone pastes something that looks like a user story:</p><pre>---<br>name: story-analyser<br>description: Proactive QA agent. Automatically flags quality issues when a user story is shared.<br>tools: Read, Grep, Glob<br>model: sonnet<br>---</pre><p>It runs a rapid triage — five to ten lines, top three issues only — and suggests next steps. The user didn’t ask for it. It just happened. That’s the behaviour I wanted: a first line of defence that catches obvious problems before any test design begins.</p><h3>Hooks</h3><p>Hooks are shell commands that Claude Code runs automatically at lifecycle events — before a tool call, after a tool call, on session start. They’re how you wire Claude into your existing toolchain.</p><p>I haven’t used them heavily in this toolkit yet, but the potential is clear: auto-format after a file write, log every change Claude makes, load environment variables at session start. Hooks close the loop between Claude’s output and the rest of your workflow.</p><h3>Commands</h3><p>Commands are the power user shortcut. Instead of running three skills in sequence, /qa-review chains them all into one consolidated document:</p><pre>story analysis → test case generation → risk prioritisation</pre><p>Output includes a final Verdict:</p><pre>🔴 BLOCKED — Story has critical issues. Resolve before test design.<br>🟠 PROCEED WITH CAUTION — Testable but has gaps.<br>🟢 READY — Well-defined. Test cases are solid.mar</pre><p>One command. Full document.</p><h3>The Problem: Copy-Paste Doesn’t Scale</h3><p>Once the toolkit was working well on one project, I ran into an obvious problem: I work across multiple products. Different repos, different teams, different contexts. Every time I wanted to use this in a new project, I was manually copying the skills, the rules, the agents. It worked, but it felt wrong.</p><p>I kept thinking: there has to be a better way to share this without duplicating everything every time.</p><h3>The Solution: Turn It Into a Plugin</h3><p>That’s when I looked properly into the Claude Code plugin system. And it turned out to be exactly what I needed.</p><p>A plugin is just a GitHub repo with a .claude-plugin/ directory and a couple of JSON config files. You define what&#39;s in the plugin, point to your markdown files, and that&#39;s it.</p><pre>{<br>  &quot;name&quot;: &quot;manual-qa-toolkit&quot;,<br>  &quot;version&quot;: &quot;1.0.0&quot;,<br>  &quot;description&quot;: &quot;A Claude Code plugin for manual QA testing based on ISTQB principles.&quot;,<br>  &quot;author&quot;: &quot;murillowelsi&quot;,<br>  &quot;skills&quot;: [<br>    &quot;skills/analyse-story/SKILL.md&quot;,<br>    &quot;skills/generate-test-cases/SKILL.md&quot;,<br>    &quot;skills/assess-risk/SKILL.md&quot;<br>  ],<br>  &quot;commands&quot;: [&quot;commands/qa-review.md&quot;, &quot;commands/rewrite-story.md&quot;],<br>  &quot;agents&quot;: [&quot;agents/story-analyser.md&quot;]<br>}</pre><p>Then a marketplace.json to make it discoverable:</p><pre>{<br>  &quot;name&quot;: &quot;manual-qa-toolkit&quot;,<br>  &quot;author&quot;: &quot;murillowelsi&quot;,<br>  &quot;repository&quot;: &quot;https://github.com/murillowelsi/manual-qa-toolkit&quot;,<br>  &quot;tags&quot;: [&quot;qa&quot;, &quot;testing&quot;, &quot;istqb&quot;, &quot;agile&quot;]<br>}</pre><p>Push to <strong>GitHub</strong>. Done. No deployment, no build, no approval process.</p><p>Now anyone — including myself on a new project — can install it with two commands:</p><pre>/plugin marketplace add murillowelsi/manual-qa-toolkit<br>/plugin install manual-qa-toolkit</pre><p>The plugin lives in one place. Updates happen in one place. No more copying files between repos.</p><h3>What I Learned</h3><p>I’m still figuring this out. But a few things became clear through building this:</p><p><strong>Rules are underrated.</strong> The ISTQB framework being always-on in every session, without me ever mentioning it, is quietly the most powerful part of the toolkit. Encoding domain knowledge as rules beats repeating it in every prompt.</p><p><strong>Agents should be lightweight.</strong> The story-analyser is intentionally shallow — three issues, a risk flag, a suggestion. It&#39;s not trying to replace the full analysis. That&#39;s what makes it useful rather than annoying.</p><p><strong>Plugins solve the duplication problem.</strong> The moment you have something that works and want to use it in more than one place, turning it into a plugin is worth the small overhead.</p><p><strong>This is not just for developers.</strong> Any domain expert — QA engineers, technical writers, security reviewers, data analysts — can encode their expertise in a CLAUDE.md and a set of skills. No code required.</p><h3>Try It</h3><pre>/plugin marketplace add murillowelsi/manual-qa-toolkit<br>/plugin install manual-qa-toolkit</pre><p>Paste a user story and run /qa-review.</p><p>Source: <a href="https://github.com/murillowelsi/manual-qa-toolkit">github.com/murillowelsi/manual-qa-toolkit</a></p><p>I’m curious whether others are building similar things. If you’ve been working with Claude Code in a more structured way, I’d love to hear how.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f7a0642d66ad" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[API Testing with Cypress — Part 1]]></title>
            <link>https://murillo-welsi.medium.com/api-testing-with-cypress-part-1-f8349e81fdff?source=rss-7ee1209d126c------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8349e81fdff</guid>
            <dc:creator><![CDATA[Murillo Welsi]]></dc:creator>
            <pubDate>Sun, 16 May 2021 09:47:38 GMT</pubDate>
            <atom:updated>2021-05-17T16:34:05.959Z</atom:updated>
            <content:encoded><![CDATA[<h3>API Testing with Cypress: Part 1</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dHPJKZXpWFoRffx1o9UV8g.jpeg" /></figure><h3>Hey folks!!</h3><p>It’s been a long time since I last wrote something here. A few days ago I was thinking about something that might be interesting to share with you about REST APIs automation testing. So the idea came to me:</p><p><em>Why not use </em><strong><em>Cypress</em></strong><em> to create a complete API testing project from scratch? We can use TDD to create the test, do all the necessary validations and put this into a CI pipeline! </em><strong>So lets go for it!</strong></p><h4>But why we should use Cypress?</h4><p>Cypress is an user-friendly testing framework, easy to create your automation and no configuration is required to start writing your tests. All the unit testing tools that you are already familiar with are included as well.</p><p>With Cypress you can do:</p><ul><li>e2e tests</li><li>unit tests</li><li>component testing</li><li>API testing</li><li>visual regression testing</li><li>and you can even combine them all</li></ul><h3>Prerequisites</h3><p>The first thing we need to do is to setup our environment. So here are some things that you should have to start this project:</p><ul><li><strong>VSCode:</strong> <a href="https://code.visualstudio.com/download">https://code.visualstudio.com/download</a></li><li><strong>Git/Github: </strong><a href="https://github.com/">https://github.com</a></li><li><strong>NPM:</strong> <a href="https://www.npmjs.com/get-npm">https://www.npmjs.com/get-npm</a></li><li><strong>NodeJS: </strong><a href="https://nodejs.org/en/download/">https://nodejs.org/en/download</a></li></ul><h3>Github</h3><p>First of all, let’s create a repository on github, it will be responsible for storing and handling the versioning of our test code. We should put a repository name, add brief description, a README and a gitignore:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*naQP5l9Ay79gxeOffoNrfA.png" /></figure><p>After that, we will clone this repository on our local machine. Fisrt, copy your repository address:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LyO8HwuTK51jEPjEAVj7Ew.png" /></figure><p>Then type in your terminal the git clone command and paste <strong>YOUR</strong> repository address. In my case, the command will be:</p><pre><strong>git clone </strong><a href="https://github.com/murillowelsi/cypress-api-tutorial.git"><strong>https://github.com/murillowelsi/cypress-api-tutorial.git</strong></a></pre><p>Open the cloned repository in your VSCode and let’s start setting up the project.</p><h3>Creating a Cypress project</h3><p>Now we’ll start a node project (default settings) by using the <strong>npm</strong> command:</p><pre><strong>npm init -y</strong></pre><p>Then we will install Cypress in the project as a <strong>dev</strong> dependencie:</p><pre><strong>npm i cypress -D</strong></pre><p>Now let’s add the following lines to the <strong>package.json</strong> file, script section:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%252874%252C144%252C226%252C1%2529%26t%3Dmaterial%26wt%3Dnone%26l%3Djavascript%26ds%3Dfalse%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DFira%2BCode%26fs%3D14px%26lh%3D152%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%252522scripts%252522%25253A%252520%25257B%25250A%252520%252520%252520%252520%252520%252522cypress%25253A%252520open%252522%25253A%252520%252522.%25252Fnode_modules%25252F.bin%25252Fcypress%252520open%252522%25252C%25250A%252520%252520%252520%252520%252520%252522cypress%25253A%252520run%252522%25253A%252520%252522.%25252Fnode_modules%25252F.bin%25252Fcypress%252520run%252520--spec%252520%252A%252A%252520%25252F%252520%252A.%252520spec.js%252522&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%25252874%25252C144%25252C226%25252C1%252529%26t%3Dmaterial%26wt%3Dnone%26l%3Djavascript%26ds%3Dfalse%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DFira%2BCode%26fs%3D14px%26lh%3D152%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25252522scripts%25252522%2525253A%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252522cypress%2525253A%25252520open%25252522%2525253A%25252520%25252522.%2525252Fnode_modules%2525252F.bin%2525252Fcypress%25252520open%25252522%2525252C%2525250A%25252520%25252520%25252520%25252520%25252520%25252522cypress%2525253A%25252520run%25252522%2525253A%25252520%25252522.%2525252Fnode_modules%2525252F.bin%2525252Fcypress%25252520run%25252520--spec%25252520%25252A%25252A%25252520%2525252F%25252520%25252A.%25252520spec.js%25252522&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/0d048141ca231c1caa44217939e9a115/href">https://medium.com/media/0d048141ca231c1caa44217939e9a115/href</a></iframe><p>The <strong>package.json</strong> will look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hpMQAS-zwY2BBrjCVXZZ-Q.png" /></figure><p>To start the Cypress project run the command:</p><pre><strong>npm run cypress:open</strong></pre><p>After executing this command, a sample Cypress project structure will be created:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jEXMHOoe1RucYFY6ADcpzw.png" /></figure><p>We will not use this samples in this tutorial, so let&#39;s remove the entire examples folder:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/298/1*x9sWTpBAYCbNAfWcDyjyyA.png" /></figure><pre><strong>rm -rf cypress/integration/examples/</strong></pre><p>With the Integration folder clean, let’s move on to the next step.</p><h3>Creating our first test</h3><p>Within Integration we will create a file called <strong>test</strong>with the <strong>spec.js </strong>extension<strong> </strong>— to be identified and executed as a test spec, and we will start to write our first test.</p><p>Mocha offers us the following test organization structure:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%252874%252C144%252C226%252C1%2529%26t%3Dmaterial%26wt%3Dnone%26l%3Djavascript%26ds%3Dfalse%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DFira%2BCode%26fs%3D14px%26lh%3D152%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Ddescribe%2528%2527Mocha%2525E2%252580%252599s%252520interface%2527%25252C%252520%2528%2529%252520%25253D%25253E%252520%25257B%25250A%252520%252520context%2528%2527it%252520provides%252520a%252520way%252520to%252520keep%252520tests%252520easier%252520to%252520read%252520and%252520organized.%2527%25252C%252520%2528%2529%252520%25253D%25253E%252520%25257B%25250A%252520%252520%252520%252520it%2528%2527This%252520is%252520your%252520test%252520case%2527%25252C%252520%2528%2529%252520%25253D%25253E%252520%25257B%25250A%252520%252520%252520%252520%252520%252520expect%2528true%2529.to.eq%2528true%2529%25250A%252520%252520%252520%252520%25257D%2529%25253B%25250A%252520%252520%25257D%2529%25253B%25250A%25257D%2529%25253B&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%25252874%25252C144%25252C226%25252C1%252529%26t%3Dmaterial%26wt%3Dnone%26l%3Djavascript%26ds%3Dfalse%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DFira%2BCode%26fs%3D14px%26lh%3D152%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Ddescribe%252528%252527Mocha%252525E2%25252580%25252599s%25252520interface%252527%2525252C%25252520%252528%252529%25252520%2525253D%2525253E%25252520%2525257B%2525250A%25252520%25252520context%252528%252527it%25252520provides%25252520a%25252520way%25252520to%25252520keep%25252520tests%25252520easier%25252520to%25252520read%25252520and%25252520organized.%252527%2525252C%25252520%252528%252529%25252520%2525253D%2525253E%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520it%252528%252527This%25252520is%25252520your%25252520test%25252520case%252527%2525252C%25252520%252528%252529%25252520%2525253D%2525253E%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520expect%252528true%252529.to.eq%252528true%252529%2525250A%25252520%25252520%25252520%25252520%2525257D%252529%2525253B%2525250A%25252520%25252520%2525257D%252529%2525253B%2525250A%2525257D%252529%2525253B&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/073b563029640a74b3e8ae01a6917a01/href">https://medium.com/media/073b563029640a74b3e8ae01a6917a01/href</a></iframe><p>A spec has three main building blocks that you can see above. This will make it easier to read the tests:</p><ul><li><strong>describe()</strong> function is a way to group tests in Mocha.</li><li><strong>context()</strong> function is another level of grouping tests according to the test context.</li><li><strong>it()</strong> function is used to put the title of it in a human-readable way to describe the test case.</li></ul><p>Let’s save the <strong>test.spec.js</strong> file and run the command:</p><pre><strong>npm run cypress: run</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e-t1Qph0ll9_OzOglnE4HA.png" /></figure><p>We can also force an error to see how it will be displayed in terminal:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%252874%252C144%252C226%252C1%2529%26t%3Dmaterial%26wt%3Dnone%26l%3Djavascript%26ds%3Dfalse%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DFira%2BCode%26fs%3D14px%26lh%3D152%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Ddescribe%2528%2527Mocha%2525E2%252580%252599s%252520interface%2527%25252C%252520%2528%2529%252520%25253D%25253E%252520%25257B%25250A%252520%252520context%2528%2527it%252520provides%252520a%252520way%252520to%252520keep%252520tests%252520easier%252520to%252520read%252520and%252520organized.%2527%25252C%252520%2528%2529%252520%25253D%25253E%252520%25257B%25250A%252520%252520%252520%252520it%2528%2527This%252520is%252520your%252520test%252520case%2527%25252C%252520%2528%2529%252520%25253D%25253E%252520%25257B%25250A%252520%252520%252520%252520%252520%252520expect%2528true%2529.to.eq%2528false%2529%25250A%252520%252520%252520%252520%25257D%2529%25253B%25250A%252520%252520%25257D%2529%25253B%25250A%25257D%2529%25253B&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%25252874%25252C144%25252C226%25252C1%252529%26t%3Dmaterial%26wt%3Dnone%26l%3Djavascript%26ds%3Dfalse%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DFira%2BCode%26fs%3D14px%26lh%3D152%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Ddescribe%252528%252527Mocha%252525E2%25252580%25252599s%25252520interface%252527%2525252C%25252520%252528%252529%25252520%2525253D%2525253E%25252520%2525257B%2525250A%25252520%25252520context%252528%252527it%25252520provides%25252520a%25252520way%25252520to%25252520keep%25252520tests%25252520easier%25252520to%25252520read%25252520and%25252520organized.%252527%2525252C%25252520%252528%252529%25252520%2525253D%2525253E%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520it%252528%252527This%25252520is%25252520your%25252520test%25252520case%252527%2525252C%25252520%252528%252529%25252520%2525253D%2525253E%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520expect%252528true%252529.to.eq%252528false%252529%2525250A%25252520%25252520%25252520%25252520%2525257D%252529%2525253B%2525250A%25252520%25252520%2525257D%252529%2525253B%2525250A%2525257D%252529%2525253B&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/89f0382f5ab00152d02bb33e81d99b7d/href">https://medium.com/media/89f0382f5ab00152d02bb33e81d99b7d/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aMyqhA-DEJJ0sVkQOW5sQw.png" /></figure><h3>Target API</h3><p>We will use the Serverest API project as the target of our tests. This API was developed by the opensource community, which allows us to test the most used HTTP methods. You can consult the available methods in the documentation - <a href="https://serverest.dev/">https://serverest.dev/</a>.</p><p>Now let’s create a new file called <strong>GETProdutos.spec.js</strong> and make the first call to the target API, using the GET verb in the /produtos route, in order to get a list of products.</p><p>To make an HTTP request we must use the <strong>cy.request()</strong> function, passing the <strong>method</strong> and <strong>url</strong>:</p><pre>Syntax:<br><strong>cy.request(method, url)</strong></pre><ul><li><strong>method (String):</strong> GET,POST, PUT, DELETE. If no method is defined, Cypress uses the <strong>GET</strong> method by default.</li><li><strong>url (String):</strong> The URL to make the request to.</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%252874%252C144%252C226%252C1%2529%26t%3Dmaterial%26wt%3Dnone%26l%3Djavascript%26ds%3Dfalse%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DFira%2BCode%26fs%3D14px%26lh%3D152%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25252F%25252F%25252F%252520%25253Creference%252520types%25253D%252522cypress%252522%252520%25252F%25253E%25250A%25250Adescribe%2528%2527Products%252520api%2527%25252C%252520%2528%2529%252520%25253D%25253E%252520%25257B%25250A%252520%252520%252520%252520context%2528%2527GET%252520%25252Fprodutos%2527%25252C%252520%2528%2529%252520%25253D%25253E%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520it%2528%2527should%252520return%252520a%252520list%252520with%252520all%252520products%2527%25252C%252520%2528%2529%252520%25253D%25253E%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520cy.request%2528%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520method%25253A%252520%2527GET%2527%25252C%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520url%25253A%252520%2527https%25253A%25252F%25252Fserverest.dev%25252Fprodutos%2527%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%25257D%2529%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520.should%2528%2528response%2529%252520%25253D%25253E%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520cy.log%2528JSON.stringify%2528response.body%2529%2529%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%25257D%2529%25253B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%25257D%2529%25253B%25250A%252520%252520%252520%252520%25257D%2529%25253B%25250A%25257D%2529%25253B&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%25252874%25252C144%25252C226%25252C1%252529%26t%3Dmaterial%26wt%3Dnone%26l%3Djavascript%26ds%3Dfalse%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DFira%2BCode%26fs%3D14px%26lh%3D152%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%2525252F%2525252F%2525252F%25252520%2525253Creference%25252520types%2525253D%25252522cypress%25252522%25252520%2525252F%2525253E%2525250A%2525250Adescribe%252528%252527Products%25252520api%252527%2525252C%25252520%252528%252529%25252520%2525253D%2525253E%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520context%252528%252527GET%25252520%2525252Fprodutos%252527%2525252C%25252520%252528%252529%25252520%2525253D%2525253E%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520it%252528%252527should%25252520return%25252520a%25252520list%25252520with%25252520all%25252520products%252527%2525252C%25252520%252528%252529%25252520%2525253D%2525253E%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520cy.request%252528%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520method%2525253A%25252520%252527GET%252527%2525252C%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520url%2525253A%25252520%252527https%2525253A%2525252F%2525252Fserverest.dev%2525252Fprodutos%252527%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525257D%252529%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520.should%252528%252528response%252529%25252520%2525253D%2525253E%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520cy.log%252528JSON.stringify%252528response.body%252529%252529%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525257D%252529%2525253B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525257D%252529%2525253B%2525250A%25252520%25252520%25252520%25252520%2525257D%252529%2525253B%2525250A%2525257D%252529%2525253B&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4b1cdfc05e95626cc37b3f9586376aa2/href">https://medium.com/media/4b1cdfc05e95626cc37b3f9586376aa2/href</a></iframe><p>The <strong>.should() </strong>function is modeled identically to the way <strong>Promises</strong> work in JavaScript. Whatever is returned from the callback function becomes the new subject and will flow into the next command.</p><p>Passing a function to <strong>.should()</strong> enables you to make multiple assertions on the yielded subject. For now we will not make any assertions, we will just throw the result on the screen using <strong>cy.log()</strong>.</p><p>Let’s run the <strong>cypress:open</strong> command this time to check the results directly in the browser:</p><pre><strong>npm run cypress:open</strong></pre><p>The following window will be displayed. Then click on the test spec that you want to run:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y0zIkZIdCN9fJmvzDl4hEw.png" /></figure><p>Cypress will open the browser, run the tests and show the results on the screen:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OTH4CK4nJMAgIFyby453bw.png" /></figure><p>Finally, let’s add some assertions inside our <strong>it()</strong> function, so that this becomes a real test.</p><p>To validate that the status code we want is actually 200, add the following line:</p><pre><strong>expect(<em>response</em>.status).to.eq(200)</strong></pre><p>Access the products endpoint directly in your browser (<a href="https://serverest.dev/produtos">https://serverest.dev/produtos</a>) to see what kind of assertions we can make in the response body.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*upFjVpltb1FJfx-pMrr0TQ.png" /></figure><p>We also can say that we expect that the ‘quantidade’ key should always be <strong>2</strong>, since the registered data is removed daily in the ServeRest project. So the size of the produtos array will also be <strong>2</strong>.</p><p>Add these two validations:</p><pre><strong>expect(<em>response</em>.body.quantidade).to.eq(2)</strong></pre><pre><strong>expect(<em>response</em>.body.produtos.length).to.be.eq(2);</strong></pre><p>And as a last validation, we can also say that the objects within the product array must contain the keys ‘name’, ‘price’, ‘description’, ‘quantity’, ‘_id’.</p><pre><strong>expect(<em>response</em>.body.produtos[0]).to.have.all.keys(<br>  &#39;nome&#39;, &#39;preco&#39;, &#39;descricao&#39;, &#39;quantidade&#39;, &#39;_id&#39;<br>)</strong></pre><p>Our test will look like this:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%252874%252C144%252C226%252C1%2529%26t%3Dmaterial%26wt%3Dnone%26l%3Djavascript%26ds%3Dfalse%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DFira%2BCode%26fs%3D11px%26lh%3D171%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25252F%25252F%25252F%252520%25253Creference%252520types%25253D%252522cypress%252522%252520%25252F%25253E%25250A%25250Adescribe%2528%2527Products%252520api%2527%25252C%252520%2528%2529%252520%25253D%25253E%252520%25257B%25250A%252520%252520%252520%252520context%2528%2527GET%252520%25252Fprodutos%2527%25252C%252520%2528%2529%252520%25253D%25253E%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520it%2528%2527should%252520return%252520a%252520list%252520with%252520all%252520products%2527%25252C%252520%2528%2529%252520%25253D%25253E%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520cy.request%2528%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520method%25253A%252520%2527GET%2527%25252C%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520url%25253A%252520%2527https%25253A%25252F%25252Fserverest.dev%25252Fprodutos%2527%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%25257D%2529%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520.should%2528%2528response%2529%252520%25253D%25253E%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520expect%2528response.status%2529.to.eq%2528200%2529%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520expect%2528response.body.quantidade%2529.to.eq%25282%2529%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520expect%2528response.body.produtos.length%2529.to.be.eq%25282%2529%25253B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520expect%2528response.body.produtos%25255B0%25255D%2529.to.have.all.keys%2528%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%2527nome%2527%25252C%252520%2527preco%2527%25252C%252520%2527descricao%2527%25252C%252520%2527quantidade%2527%25252C%252520%2527_id%2527%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%2529%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%25257D%2529%25253B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%25257D%2529%25253B%25250A%252520%252520%252520%252520%25257D%2529%25253B%25250A%25257D%2529%25253B%25250A&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%25252874%25252C144%25252C226%25252C1%252529%26t%3Dmaterial%26wt%3Dnone%26l%3Djavascript%26ds%3Dfalse%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DFira%2BCode%26fs%3D11px%26lh%3D171%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%2525252F%2525252F%2525252F%25252520%2525253Creference%25252520types%2525253D%25252522cypress%25252522%25252520%2525252F%2525253E%2525250A%2525250Adescribe%252528%252527Products%25252520api%252527%2525252C%25252520%252528%252529%25252520%2525253D%2525253E%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520context%252528%252527GET%25252520%2525252Fprodutos%252527%2525252C%25252520%252528%252529%25252520%2525253D%2525253E%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520it%252528%252527should%25252520return%25252520a%25252520list%25252520with%25252520all%25252520products%252527%2525252C%25252520%252528%252529%25252520%2525253D%2525253E%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520cy.request%252528%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520method%2525253A%25252520%252527GET%252527%2525252C%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520url%2525253A%25252520%252527https%2525253A%2525252F%2525252Fserverest.dev%2525252Fprodutos%252527%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525257D%252529%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520.should%252528%252528response%252529%25252520%2525253D%2525253E%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520expect%252528response.status%252529.to.eq%252528200%252529%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520expect%252528response.body.quantidade%252529.to.eq%2525282%252529%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520expect%252528response.body.produtos.length%252529.to.be.eq%2525282%252529%2525253B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520expect%252528response.body.produtos%2525255B0%2525255D%252529.to.have.all.keys%252528%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%252527nome%252527%2525252C%25252520%252527preco%252527%2525252C%25252520%252527descricao%252527%2525252C%25252520%252527quantidade%252527%2525252C%25252520%252527_id%252527%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%252529%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525257D%252529%2525253B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525257D%252529%2525253B%2525250A%25252520%25252520%25252520%25252520%2525257D%252529%2525253B%2525250A%2525257D%252529%2525253B%2525250A&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/47a940b93ab68632c80d5a508ce346be/href">https://medium.com/media/47a940b93ab68632c80d5a508ce346be/href</a></iframe><p>If we run the tests again, we will see that all assertions are passing successfully.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xo-c_ohTqxMxcc3-5dh6nQ.png" /></figure><h3>Success! We wrote our first API tests using Cypress.</h3><p>We should not forget to send our code to Github, after all we want to save and version the project.</p><blockquote>The purpose of this article is not to show you how to use git but let’s see some commands that can help you push your code to Github.</blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fcnhpl4IeYgU7MCBdV2%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fcnhpl4IeYgU7MCBdV2%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2Fcnhpl4IeYgU7MCBdV2%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="767" frameborder="0" scrolling="no"><a href="https://medium.com/media/eef63899cbee485e1c0e39700ff49cbf/href">https://medium.com/media/eef63899cbee485e1c0e39700ff49cbf/href</a></iframe><p>Let’s add some things to our <strong>.gitignore</strong> file that we don’t want to send to the remote repository:</p><pre><strong># Dependency directories</strong></pre><pre><strong>node_modules/</strong></pre><pre><strong>videos/</strong></pre><pre><strong>screenshots/</strong></pre><pre><strong>package-lock.json</strong></pre><p>Run the command <strong>git add</strong> o add all files to the staging area on the terminal.</p><pre><strong>git add .</strong></pre><p>Use <strong>git status</strong> to display the list of changed files to be committed.</p><pre><strong>git status</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*i6LWDlcGp2y_Nr30t3Xq_g.png" /></figure><p>Then run the <strong>git commit </strong>that will create a snapshot of the changes and save it to the git directory. We use the <strong>-m</strong> parameter to add a message to the commit, tell what was changed.</p><pre><strong>git commit -m &quot;First cypress project commit&quot;</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*1DiRug4dDtwljek0hqM9oA.png" /></figure><p>Finally we are going to push the changes from our origin repository to the main repository using <strong>git push</strong>.</p><pre><strong>git push origin main</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*AdB7fUKJ22nXdfogBRa7mA.png" /></figure><p>If we check our repository on Github, we will see all the changes we’ve made in the main branch:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vt1A3NstATOf0aPEgIC16g.png" /></figure><p>This is the link to my github repository, just in case you want to take a look:<br><a href="https://github.com/murillowelsi/cypress-api-tutorial">https://github.com/murillowelsi/cypress-api-tutorial</a></p><p>So we’ve just finished the first part of this series of articles that I want to share with you guys. In the next one, we will refactor this test project to make it more reliable and robust.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FdsKnRuALlWsZG%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fthe-office-steve-carell-michael-scott-dsKnRuALlWsZG&amp;image=https%3A%2F%2Fmedia3.giphy.com%2Fmedia%2FdsKnRuALlWsZG%2Fgiphy.gif%3Fcid%3D790b7611736d0180c2d4f2da9b397628d7ceb0bb3e2c9b7b%26rid%3Dgiphy.gif%26ct%3Dg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="245" frameborder="0" scrolling="no"><a href="https://medium.com/media/ca20fff7ababc9d301196d0e7157dc7c/href">https://medium.com/media/ca20fff7ababc9d301196d0e7157dc7c/href</a></iframe><h3>See ya next time!</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8349e81fdff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ambientes ready-to-code usando Gitpod]]></title>
            <link>https://murillo-welsi.medium.com/ambientes-ready-to-code-usando-gitpod-7a0e3233dd08?source=rss-7ee1209d126c------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a0e3233dd08</guid>
            <dc:creator><![CDATA[Murillo Welsi]]></dc:creator>
            <pubDate>Tue, 25 Feb 2020 00:01:59 GMT</pubDate>
            <atom:updated>2020-02-25T00:01:59.599Z</atom:updated>
            <content:encoded><![CDATA[<h4>Como usar um ambiente de desenvolvimento completo via browser para escrever e executar testes automatizados</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2eyNxpUN5T2bu3qXBdXv3A.png" /></figure><p>Com a constante evolução da tecnologia, novas ideias surgem a todo momento e aprimoram os métodos utilizados em TI. O container docker é uma delas, pois trouxe várias vantagens, como a criação de ambientes isolados e portáveis, aumentando a eficiência e facilitando a implantação em ambientes de homologação e/ou de produção. Mas e se eu te disser que, além de containerizar aplicações, também é possível fazer isso com todo o seu ambiente de desenvolvimento? Vamos conhecer a ferramenta Gitpod.</p><h3>Gitpod</h3><p>O Gitpod é uma IDE de desenvolvimento com o <strong>VS Code</strong> online, que pode ser executada diretamente pelo browser. Essa ferramenta possui integração com o <strong>Github </strong>e o <strong>Gitlab</strong>, e, em segundos, um ambiente ready-to-code (pronto para codar) totalmente funcional é criado.</p><h4>Arquitetura</h4><p>O Gitpod roda em diversos clusters Kubernetes hospedados na infraestrutura da Google Cloud Platform. Quando um ambiente é iniciado, o Gitpod irá selecionar o cluster mais próximo à sua localização e iniciar o pod do Kubernetes.</p><p>Podemos usar qualquer imagem do Docker para “dar vida” aos nossos ambientes de desenvolvimento, e os criar de forma automatizada, eliminando os famosos cenários “na minha máquina funciona”. Os ambientes criados no Gitpod são descartáveis. Você simplesmente cria um novo sempre que precisar. A ferramenta também permite acesso ao terminal com todos os recursos para executar qualquer processo, como compilar ou executar testes.</p><h4>O Gitpod é free?</h4><p>O Gitpod is free até 50 horas de uso por mês para qualquer repositório público, mas também possui algumas opções de planos que podem ser consultados em <a href="https://www.gitpod.io/pricing/">https://www.gitpod.io/pricing/</a>.</p><h3>Criando um ambiente de desenvolvimento no Gitpod usando um repositório do Github</h3><p>Primeiramente, crie uma conta no <a href="https://gitpod.io/login/">https://gitpod.io/login/</a>. É muito simples, basta logar usando sua conta do Github ou Gitlab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xdhwape49GLfV4G9tPYaiw.png" /></figure><p>Depois, precisamos ter um repositório com o nosso código no Github. Caso não possua nenhum repositório com código, crie um fork do meu projeto clicando no botão “<strong>Fork”</strong>, conforme a imagem abaixo:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DhP32gj55hjCrXAKaehkfg.png" /></figure><p>Acesse seu repositório e, na barra de endereço do browser, adicione o prefixo <strong>“<em>https: //gitpod.io#</em>”</strong> no endereço do github. Exemplo:</p><p><strong><em>https://gitpod.io#</em></strong><a href="https://github.com/murillowelsi/api-tests"><strong><em>https://github.com/murillowelsi/api-tests</em></strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FoKamBj6-GJXx66TgPWvSg.png" /></figure><p><strong><em>Obs.:</em></strong><em> O projeto que usarei como exemplo usa a linguagem Ruby com algumas gems para execução de testes automatizados em APIs, porém, podemos utilizar qualquer outra linguagem sem problemas.</em></p><p>Após apertar o botão “Enter”, em questão de segundos o ambiente estará de pé e pronto para ser utilizado.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FpLgei6cp6V4Qz6crlNElg.png" /></figure><p>Note que o Gitpod é identico ao VS Code, e possui as mesmas funcionalidades. Se executarmos no terminal o comando:</p><pre>ruby -v</pre><p>veremos que o ambiente já está com o Ruby instalado.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rTQiYD3BIagx3_RmAtmf7A.png" /></figure><p>Se executarmos no terminal o comando:</p><pre>bundle -v</pre><p>veremos que o gerenciador de pacotes do Ruby também já está instalado.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lpUHnMRRdFXBrpfTDsKKBQ.png" /></figure><p>Vamos instalar então as dependências necessárias para que o projeto seja executado. Para isto, digite o comando:</p><pre>bundle install</pre><p>Então todas as gems especificadas no arquivo Gemfile serão instaladas:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OoaE0Ken1RP9T8o20WbJUA.png" /></figure><p>Este é um projeto que utiliza as gems <strong>HTTParty </strong>e<strong> Rspec.</strong></p><ul><li><strong>HTTParty:</strong> para fazer uso dos métodos HTTP e fazer requisições em APIs</li><li><strong>Rspec:</strong> ferramenta de teste escrita em Ruby para testar o código Ruby.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mMosMeLs0HKNgEigD9MZyQ.png" /></figure><p>Para executar os testes automatizados deste projeto, usarei o comando do Rspec:</p><pre>rspec</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xkserxDIxzx9NZPt233ldg.png" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FccRdPf8zWkivm%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fsingle-understand-ccRdPf8zWkivm&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FccRdPf8zWkivm%2F200.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/088b180ae9d63e03d4593853d6e53298/href">https://medium.com/media/088b180ae9d63e03d4593853d6e53298/href</a></iframe><p>Perceba que em poucos passos criamos nosso ambiente, instalamos as dependências e executamos os cenários de teste sem dificuldades.</p><h4>Compartilhamento de ambiente</h4><p>Outra funcionalidade sensacional do Gitpod é a de compatilhamento de ambiente. Para isto, selecione o botão do seu perfil e note que temos duas opções:</p><ul><li><strong>Share Workspace Snapshot:</strong> O estado atual é capturado em um snapshot. Compartilhando o link gerado permitirá que qualquer pessoa crie sua própria cópia do seu Workspace.</li><li><strong>Share Running Workspace: </strong>Qualquer pessoa que possuo o link gerado terá acesso ao seu Workspace que está rodando em tempo real.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GHgBLvx9qzmRNKcJIOFJ0Q.png" /></figure><p>Particularmente, acho a função de compartilhamento muito interessante, pois, imagine um cenário onde estamos escrevendo nosso código e precisamos de uma ajuda ou suporte. Com essa funcionalidade, podemos gerar snapshot e enviar o link para que uma pessoa execute exatamente o mesmo ambiente, facilitando a tarefa de identificar e solucionar o problema.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FjsN192JGdyWvS1gqTb%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Frickandmorty-season-1-adult-swim-rick-and-morty-jsN192JGdyWvS1gqTb&amp;image=https%3A%2F%2Fmedia4.giphy.com%2Fmedia%2FjsN192JGdyWvS1gqTb%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/9efac71c8a36e453d18217be3df0d004/href">https://medium.com/media/9efac71c8a36e453d18217be3df0d004/href</a></iframe><p>Para finalizar, podemos concluir que apesar de uma ótima ferramenta, não aconselho o uso do Gitpod (no plano free) em projetos corporativos, pois o repositório deve ser público e temos limite de horas de uso. Porém o fato de termos uma IDE containerizada e pronta para executarmos diretamente de qualquer navegador sem necessidade de nenhuma ferramenta instalada é incrível, e em uma emergência ou para projetos pessoais pode ser extremamente útil.</p><p>Para consultar a documentação completa do Gitpod acesse: <a href="https://www.gitpod.io/docs/">https://www.gitpod.io/docs/</a> .</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3XiQswSmbjBiU%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fdisney-dog-no-3XiQswSmbjBiU&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3XiQswSmbjBiU%2F200.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="238" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd39b7d84a45a2b749ddaa87b4f14eda/href">https://medium.com/media/dd39b7d84a45a2b749ddaa87b4f14eda/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a0e3233dd08" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Testando uma API de Filmes com Postman]]></title>
            <link>https://murillo-welsi.medium.com/testando-uma-api-de-filmes-com-postman-80f2efe8ccea?source=rss-7ee1209d126c------2</link>
            <guid isPermaLink="false">https://medium.com/p/80f2efe8ccea</guid>
            <category><![CDATA[postman]]></category>
            <category><![CDATA[qa]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[api-testing]]></category>
            <category><![CDATA[test-automation]]></category>
            <dc:creator><![CDATA[Murillo Welsi]]></dc:creator>
            <pubDate>Sun, 02 Feb 2020 15:48:37 GMT</pubDate>
            <atom:updated>2020-02-03T22:48:37.601Z</atom:updated>
            <content:encoded><![CDATA[<h4>Como testar APIs usando Postman, e como automatizar testes com Runner e Newman</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*ukQmJSxL8Rg1A_5VyfZ59Q.png" /></figure><h3>Um breve overview sobre APIs</h3><p>Uma API é um conjunto de definições e protocolos usado no desenvolvimento e na <a href="https://www.redhat.com/pt-br/topics/integration">integração</a> de software. Com as APIs é possível realizar integrações entre soluções ou serviços sem precisar se preocupar com linguagem, infraestrutura e ferramentas que foram utilizadas em sua implementação. O uso de APIs permite:</p><ul><li>Facilidade na integração mobile-cloud</li><li>Grande poder de integração entre aplicações</li><li>Viabilizar parcerias</li><li>Customização de serviços</li><li>Impulsiona a inovação aberta</li></ul><p>Devemos pensar na API como um <strong>contrato</strong>. Ela possui uma documentação que representa um acordo entre as partes interessadas, e, para que tenhamos sucesso nas solicitações, é necessário respeitar esta documentação.</p><h4>REST</h4><p>Representational State Transfer ou REST, é um estilo de arquitetura a ser utilizado para se projetar software distribuído, baseadas em comunicação via rede. O REST foi criado por Roy Fielding, um dos principais criadores do protocolo HTTP.</p><h4>RESTful</h4><p>Podemos dizer que uma API é RESTful, quando ela utiliza um design que respeita os conceitos de REST.</p><h4>URI — Uniform Resource Identifier</h4><p>A URI é o identificador de um recurso, pois tudo o que está disponível na internet precisa de um identificador único. Por exemplo, o identificador de uma página pode ser: <a href="https://github.com/murillowelsi">https://github.com/murillowelsi</a> .</p><p>Abaixo temos uma imagem que ilustra qual deve ser a estrutura básica de uma URI:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wWRMiE8aOXJz-vrmFJyAmQ.png" /><figcaption>Fonte: <a href="https://pt.slideshare.net/frosato/apis-gerenciadas-de-ponta-a-ponta-40570765">https://pt.slideshare.net/frosato/apis-gerenciadas-de-ponta-a-ponta-40570765</a></figcaption></figure><h4>Métodos HTTP</h4><p>Os recursos de uma aplicação podem ser manipulados de diversas maneiras. É possível criá-los, atualizá-los, excluí-los, dentre outras operações.</p><p>Quando fazemos uma requisição HTTP para um serviço, devemos informar URI para identificar quais recursos pretendemos manipular, e também informe o tipo de manipulação que queremos fazer no recurso. Para isso, utilizaremos os métodos do protocolo HTTP.</p><p>O protocolo HTTP possui diversos métodos, sendo que cada um possui uma função diferente. Os métodos HTTP mais utilizados são:</p><ul><li><strong>GET: </strong>Utilizamos o GET para recuperar os dados de um recurso.</li><li><strong>POST:</strong> O POST é utilizado quando desejamos criar um novo recurso.</li><li><strong>PUT:</strong> É utilizado quando queremos fazer uma alteração em um determinado recurso já existente.</li><li><strong>PATCH:</strong> Utilizado para atualizar parcialmente um determinado recurso.</li><li><strong>DELETE: </strong>Utilizado para excluir um determinado recurso.</li></ul><p>Na próxima seção veremos na prática, a utilização dos métodos HTTP em um serviço REST.</p><h4>HTTP Status-Code</h4><p>Os códigos de retorno do protocolo (Status-Code) são basicamente um algarismo de três dígitos que é o resultado de uma tentativa de entendimento de uma requisição, isto é, sempre que você interage via HTTP, você obtém um código de retorno. As principais classes de status-code são:</p><h4>2xx Sucesso</h4><p>A classe de códigos de status 2xx indica a ação solicitada pelo cliente foi recebida, compreendida, aceita e processada com êxito. Exemplo:</p><p><strong><em>200 OK :</em></strong><em> A requisição foi concluída com sucesso!</em></p><h4>4xx Erro de cliente</h4><p>A classe 4xx de código de status é destinado para os casos em que o servidor não conseguiu processar a solicitação porque o cliente a fez de forma errada ou que não dependa dele, como por exemplo uma página excluída. Por exemplo:</p><p><strong><em>400 Bad Request: </em></strong><em>A requisição não pôde ser entendida pelo servidor devido à sintaxe malformada.</em></p><h4>5xx Erro do servidor</h4><p>Indica um erro do servidor ao processar a solicitação. Por exemplo:</p><p><strong><em>500 Internal Server Error: </em></strong><em>O servidor encontrou uma situação com a qual não sabe lidar.</em></p><blockquote>IMPORTANTE: Consulte os Status-Code e seus significados em: <a href="https://httpstatuses.com/">https://httpstatuses.com/</a></blockquote><p>É importante dizer que essas informações te deixam apto a entender o <strong>básico</strong> do funcionamento de uma API, porém elas podem ser bem mais complexas em um projeto real.</p><h3>Hands-on — Testando a API do TMDb</h3><p>Usaremos a API da <strong>Movie Database </strong>em nossos testes, que é um banco de dados de filmes e TV criado pela comunidade. Para isto, precisaremos criar uma conta, acesse o endereço:</p><p><a href="https://www.themoviedb.org/login?language=pt-BR">https://www.themoviedb.org/login?language=pt-BR</a></p><p>Após criar a conta, acesse <strong>Configurações</strong> &gt; <strong>API</strong> e anote as informações de <strong>Chave da API </strong>e o <strong>Token de Leitura da API</strong>, precisaremos delas mais tarde.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e-4c9keDH_MVD4mhX9oKuw.png" /></figure><p>Consulte sempre a documentação da API através do endereço:</p><p><a href="https://developers.themoviedb.org/3/getting-started/introduction">https://developers.themoviedb.org/3/getting-started/introduction</a></p><h3>Postman</h3><p>O Postman é um API Client que facilita criar, compartilhar, testar e documentar APIs. A ferramenta oferece uma interface de usuário elegante onde é possível criar, salvar as requisições e ler suas respostas, sem a necessidade de escrever um monte de código apenas para testar a funcionalidade de uma API.</p><p>Para instalar o Postman consulte a documentação oficial em:</p><p><a href="https://learning.getpostman.com/docs/postman/launching-postman/installation-and-updates/">https://learning.getpostman.com/docs/postman/launching-postman/installation-and-updates/</a></p><h3>Conhecendo os componentes do Postman</h3><p>A seguir apresentarei alguns componentes do Postman de uma forma prática.</p><h4>Workspace</h4><p>Nosso primeiro passo será criar um Workspace, que é um recurso que ajuda a organizar o trabalho. Podemos separar nossos projetos por clientes, orgizando em espaços de trabalho de acordo com o contexto do projeto que está testando. Também possível compartilhar espaços de trabalho com sua equipe, o que permite a colaboração em tempo real.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wbHV2ARIu_xxpQwxgxgu0Q.png" /></figure><p>Para criar nosso Workspace, selecione <strong>Create New</strong>, vamos chamá-lo de <strong>TMDb API Test</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/1*y-oOAZKmNFieUC8ElSaGPQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*8qzjmHA8F-0C7y_HJ1Rn1Q.png" /></figure><h4>Collection</h4><p>Depois de criar nosso Workspace, vamos criar uma collection, que permite o agrupamento de diferentes solicitações, organizando essas solicitações em “pastas”. Para criar uma collection, clique em <strong>New Collection</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/316/1*KKMqs6NM2N6aHCKkQxEPEw.png" /></figure><p>Dê um nome para a collection:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*hJTX4-1SfV_K5SH0c_Z_EA.png" /></figure><p>As collections são muito úteis, pois facilitam a organização e a documentação de suas requisições. Você pode criar conjuntos de testes, anexando scripts de teste a requisições e construir conjuntos de testes de integração.</p><h4>Environment</h4><p>Um environment é um conjunto de variáveis ​​que permite alternar o contexto de suas solicitações. As variáveis ​​permitem armazenar e reutilizar valores em suas solicitações e scripts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/361/1*8Q1EH3t-6upBUBlemL6hiw.png" /></figure><p>Vamos inserir a URL base do TMDb (<a href="https://api.themoviedb.org/3">https://api.themoviedb.org/3</a> ) , a api_key e o token dentro de variáveis, para que possamos reutilizá-la em todos os requests:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*LCQ4Wfnq4fyYvYMzzPH2hQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*GD7i3h0uLpUjK49Que1jUw.png" /></figure><h4>Primeiro Request</h4><p>Vamos criar agora nosso primeiro request. Será um GET que retorna os filmes mais bem avaliados na plataforma.</p><p>Siga os passos abaixo para criar um novo request:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MMnW22Lakwd4XCSG04uwsw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*7fp9xIphye5KEfwbWNhUiQ.png" /></figure><p>A URI desse request é:</p><p><a href="https://api.themoviedb.org/3/movie/top_rated"><strong>https://api.themoviedb.org/3/movie/top_rated</strong></a></p><p>Como a URL base já está na nossa environment, parassaremos o nome da variável seguindo a notação {{baseUrl}}</p><p><strong>{{baseUrl}}/movie/top_rated</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PWS5NZmUU9H6U8JidPmZlg.png" /></figure><p>Vamos inserir também os headers necessários, e clicar em Send para efetuar o request:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jpOSqlmVd8eeiBRNrk99Kg.png" /></figure><p>Agora recebemos a resposta da API, com os filmes <em>top-rated</em> e suas informações no formato JSON. Destaquei um filme (ótimo filme, por sinal) para que possamos identificar seu bloco no retorno:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g69CAYQ2XWs6n9IseNmNCw.png" /><figcaption>GET /movie/top_rated</figcaption></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FfPkWsBe1wWPtu%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fhappy-free-freedom-fPkWsBe1wWPtu&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FfPkWsBe1wWPtu%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/8e3a7e380d4a46ed87443a55dbab71dc/href">https://medium.com/media/8e3a7e380d4a46ed87443a55dbab71dc/href</a></iframe><h4>Adicionando mais requests</h4><p>Para saber quais as possibilidades de requests que podemos fazer nessa API, consulte a documentação em <a href="https://developers.themoviedb.org/3">https://developers.themoviedb.org/3</a> , conforme a imagem abaixo:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Iz6ri0nlZ3UIozH66gef1g.png" /></figure><p>Vamos adicionar mais requests em nossa collection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cEF7wsCUSagW9346y910TA.png" /><figcaption>GET /discover/movie</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UZ_A2JkhswbZ8m7zO_4nTw.png" /><figcaption>GET /movie/popular</figcaption></figure><p>Podemos utilizar <strong>Query Params</strong> para realizar filtros e buscar um filme específico. Devemos passar também o parâmetro <strong>api_key</strong>, como solicitado na documentação (<a href="https://developers.themoviedb.org/3/search/search-movies">https://developers.themoviedb.org/3/search/search-movies</a>). Vamos fazer um filtro, buscando pelo título Batman:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b05xRUxGMu4SFp8zPvAe3Q.png" /><figcaption>Query params</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sQk-v1X3zZeNIS5Z0YzrKg.png" /><figcaption>GET /search/movie</figcaption></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F4UJyRK2TXNhgk%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fspoilers-august-4UJyRK2TXNhgk&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F4UJyRK2TXNhgk%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="326" frameborder="0" scrolling="no"><a href="https://medium.com/media/788bef899f59e6821d5ee7e384605697/href">https://medium.com/media/788bef899f59e6821d5ee7e384605697/href</a></iframe><h4>Sandbox e Test Scripts</h4><p>Com o Postman é possível escrever scripts de teste para suas solicitações da API usando JavaScript. O Postman Sandbox é um ambiente de execução <strong>JavaScript</strong> disponível para você ao escrever scripts de pré-request e scripts de teste para solicitações. Vamos adicionar alguns testes básicos em nossos requests:</p><ul><li><strong>Status-Code: </strong>queremos que nossas requisições retornem <strong>200 (Sucesso)</strong>.</li><li>Validar se <strong>Content-Type</strong> e <strong>Connection</strong> são retornados no Response Header.</li></ul><p>Insira o código abaixo na aba <strong>Tests</strong>:</p><pre>// Valida status code<br>pm.test(“Status test”, function () {<br> pm.response.to.have.status(200);<br>});</pre><pre>// Valida se Content-Type é retornado no Response Header<br>pm.test(“Content-Type header is present”, function () {<br> pm.response.to.have.header(“Content-Type”);<br>});</pre><pre>// Valida se Connection é retornado no Response Header<br>pm.test(“Connection header is present”, function () {<br> pm.response.to.have.header(“Connection”);<br>});</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bM21f8MQv71b-3SZHVhAew.png" /></figure><p>Na aba <strong>Test Results</strong> podemos ver os resultados dos testes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RDwsByP8wfdGbYSeQmiSeQ.png" /></figure><p>Os testes permitem garantir que sua API esteja funcionando conforme o esperado, estabelecer que as integrações entre os serviços estejam funcionando de maneira confiável e verificar se os novos desenvolvimentos não quebraram nenhuma funcionalidade existente.</p><h4>Collection Runner</h4><p>Como vimos anteriormente, as collections são grupos de requisições que podem ser executados. Com o Runner podemos criar suítes de teste de integração usando scripts de teste e automatizar sua execução.</p><p>Vamos executar os testes usando o <strong>Runner</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/317/1*BHDQrHz3lxIv8euKsFm9Qg.png" /></figure><p>Selecione a <strong>collection</strong> e <strong>environment</strong> desejadas, e clique em <strong>Run</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PxyxWZ8tVagMFluxxzczMg.png" /></figure><p>Os testes serão exibidos em <strong>Run Results</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4oug-dzwgdIHej0MbzhqRQ.png" /></figure><h4>Newman</h4><p>O Newman é utilizado para executar o Runner do Postman via linha de comando. Ele é construído com a extensibilidade em mente, para que você possa integrá-lo facilmente aos seus servidores de Integração Contínua.</p><p>Para instalar o Newman, consulte a documentação em: <a href="https://www.npmjs.com/package/newman">https://www.npmjs.com/package/newman</a></p><p>Pra finalizar esse post (que já ficou MUITO longo), vamos executar o <strong>Runner</strong> pela linha de comando usando o <strong>Newman</strong>:</p><ul><li>Primeiro exporte sua collection, e salve em um diretório com seus testes:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/302/1*yU2gTILebwUUWyw_7F2DUg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/479/1*82kck5Yf2Az6XFlQPB6CuA.png" /></figure><ul><li>Depois exporte suas environments e salve no mesmo diretório:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*wFqGh-30-btkmO8OJ26NMQ.png" /></figure><p>Para executar, abra o terminal e navegue até o diretório que salvamos as <strong>collections</strong> e <strong>environments</strong>. O comando para executar o newman é:</p><pre>$ newman run SUA_COLLECTION --environment SUA_ENVIRONMENT</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fRbCJbBhwxw8P3NwK5e1bg.png" /></figure><p>O Newman exibirá todos os relatórios no próprio terminal.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FZt5p7rm1dWQCs%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fpost-blue-boys-Zt5p7rm1dWQCs&amp;image=https%3A%2F%2Fmedia3.giphy.com%2Fmedia%2FZt5p7rm1dWQCs%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="290" frameborder="0" scrolling="no"><a href="https://medium.com/media/b26c210fc3075e7d51d3dcbfc7d405d7/href">https://medium.com/media/b26c210fc3075e7d51d3dcbfc7d405d7/href</a></iframe><p>Assim finalizamos nossos testes com Postman, lembrando que existem diversas possibilidades, e o intuito deste post foi exibir apenas algumas delas.</p><p>Obrigado por acompanharem, e <strong>PRONTO, CHEGA!!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80f2efe8ccea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Declarative Pipelines — Jenkins]]></title>
            <link>https://murillo-welsi.medium.com/declarative-pipelines-jenkins-d84087963499?source=rss-7ee1209d126c------2</link>
            <guid isPermaLink="false">https://medium.com/p/d84087963499</guid>
            <category><![CDATA[jenkins-pipeline]]></category>
            <category><![CDATA[qa]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[continuous-integration]]></category>
            <category><![CDATA[declarative-pipeline]]></category>
            <dc:creator><![CDATA[Murillo Welsi]]></dc:creator>
            <pubDate>Sat, 25 Jan 2020 01:26:51 GMT</pubDate>
            <atom:updated>2020-01-28T12:25:04.178Z</atom:updated>
            <content:encoded><![CDATA[<h3>Declarative Pipelines — Jenkins</h3><h4>Como criar um pipeline de Integração Contínua no Jenkins + Docker</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*Z0kYtXLNEFuXjnu6JyrsCg.png" /></figure><p>Com a adoção do Ágil pelas equipes de desenvolvimento, os desenvolvedores passaram a fazer alterações no código várias vezes ao dia. Tendo em vista este cenário, vamos imaginar o que seria necessário para que uma equipe mantenha a qualidade do software.</p><p>A cada incremento no código:</p><ul><li>O desenvolvedor teria que avisar o time sobre a alteração;</li><li>Uma tarefa de teste teria que ser criada para um QA/Tester;</li><li>O QA teria que fazer o download do repositório do projeto em sua máquina e montar o ambiente;</li><li>Executar os comandos de teste unitário;</li><li>Executar os comandos de testes de integração;</li><li>Analisar relatórios gerados e anexá-los a tarefa;</li><li>Encerrar a tarefa.</li></ul><p>E se um bug fosse encontrado? Após a correção todo o processo teria de ser executado novamente.</p><p>Provavelmente encontraremos problemas como: testes longos e lentos, falhas de comunicação entre a equipe, muito tempo gasto em depuração, e o principal, demora na entrega de valor para o cliente.</p><p>Para solucionar este problema, ferramentas de <strong>Integração Contínua </strong>como o Jenkins foram criadas. Com essas ferramentas é possível automatizar este processo a cada alteração feita no código, permitindo que as equipes detectem erros rapidamente e os localizem mais facilmente.</p><p><strong>O objetivo deste passo a passo é mostrar uma maneira de configurar um pipeline usando o Jenkins com foco apenas em Integração Contínua. É uma forma eficiente de manter o time informado através de relatórios e notificações.</strong></p><p>Existem diferentes maneiras de criar pipelines no Jenkins. Os <strong>pipelines declarativos</strong> fornecem uma sintaxe simplificada e com instruções específicas.</p><h3>Criando Jobs</h3><p>Criar jobs é a principal função do Jenkins. Simplificando, você pode pensar em um job como uma tarefa específica ou passo que será executado. Isso pode envolver simplesmente compilar seu código e executar seus testes de unidade. Ou você pode querer que um trabalho de construção execute outras tarefas relacionadas, como executar seus testes de integração, medir a cobertura de código ou métricas de qualidade de código.</p><p>Para criar um job no Jenkins, devemos selecionar a opção <strong>New Item</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*h-zz6wJfuA3UWhKoYyCaXQ.png" /></figure><p>Depois deveremos criar um nome e selecionar o tipo de pipeline:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WMKFUUhbw1FKSdkKdeCNIw.png" /></figure><p>Nosso script será inserido na seção <strong>Pipeline</strong>, conforme a imagem abaixo:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GVM-HtthRrh2cVv_VFGYrw.png" /></figure><blockquote><strong>Importante: Use e abuse da opção Pipeline Sintax para obter ajuda ao criar o script, usando função Snippet Generator.</strong></blockquote><h3>Plugins</h3><p>Os plugins são o principal meio de aprimorar a funcionalidade de um ambiente Jenkins para atender às necessidades específicas da organização ou do usuário. Para entender como instalar e gerenciar plugins no Jenkins, consulte a documentação através do link: <a href="https://jenkins.io/doc/book/managing/plugins/">https://jenkins.io/doc/book/managing/plugins/</a></p><p>Serão necessários os seguintes plugins:</p><ul><li><strong>Git (</strong><a href="https://plugins.jenkins.io/git">https://plugins.jenkins.io/git</a><strong>)</strong></li><li><strong>Cucumber reports (</strong><a href="https://plugins.jenkins.io/cucumber-reports">https://plugins.jenkins.io/cucumber-reports</a><strong>)</strong></li><li><strong>Jacoco Plugin (</strong><a href="https://wiki.jenkins-ci.org/display/JENKINS/JaCoCo+Plugin">https://wiki.jenkins-ci.org/display/JENKINS/JaCoCo+Plugin</a><strong>)</strong></li><li><strong>Docker Pipeline (</strong><a href="https://github.com/jenkinsci/docker-workflow-plugin">https://github.com/jenkinsci/docker-workflow-plugin</a><strong>)</strong></li><li><strong>HTML Publisher plugin (</strong><a href="http://wiki.jenkins-ci.org/display/JENKINS/HTML+Publisher+Plugin">http://wiki.jenkins-ci.org/display/JENKINS/HTML+Publisher+Plugin</a><strong>)</strong></li><li><strong>Slack Notification Plugin (</strong><a href="https://github.com/jenkinsci/slack-plugin">https://github.com/jenkinsci/slack-plugin</a><strong>)</strong></li></ul><p><em>Explicar o funcionamento de cada plugin não está no escopo deste post, mas você pode consultar suas respectivas documentações nos links descritos acima.</em></p><h4>Slack Notification</h4><p>Faremos uma simples configuração para que o plugin do Slack funcione corretamente. Para isto, acesse o menu <strong>Manage Jenkins</strong> &gt; <strong>Configure System</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CPmfRckcFWdRuD96mp_GDw.png" /></figure><p>Insira as informações do seu <strong>Workspace</strong> e <strong>Channel </strong>no Slack:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*9SjY30R_6ei5taNPjkkoRA.png" /></figure><h3>Criando a estrutura do Pipeline</h3><p>Os pipelines declarativos devem ser colocados dentro de um bloco de <strong>pipeline</strong>, por exemplo:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/419523a9b228fa674942be06e28dbe6b/href">https://medium.com/media/419523a9b228fa674942be06e28dbe6b/href</a></iframe><p>Dentro deste bloco, devemos incluir o código referente às seções do seu pipeline. Elas irão definir sua estrutura e como será executado. Neste caso, usaremos as seguintes:</p><ul><li>Agent</li><li>Stages &amp; Steps</li><li>Post</li></ul><h4>Agent</h4><p>A seção <strong>agent</strong> especifica que o Pipeline inteiro, será executado em um container <strong>Docker </strong>no ambiente Jenkins.</p><p>O parâmetro <strong>image</strong> faz download de uma imagem Docker do<strong> maven: 3-alpine </strong>(caso não exista na sua máquina), e executa essa imagem como um contêiner separado.</p><p>Este contêiner Maven se torna a máquina que Jenkins usará para executar seu projeto de Pipeline. No entanto, esse contêiner tem vida curta, ou seja, é criado durante o início e depois é removido no final do seu pipeline.</p><p>O parâmetro args cria um mapeamento entre os diretórios /root/.m2 (repositório Maven) no contêiner <strong>Maven Docker </strong>e o do sistema de arquivos do <strong>host</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c2f8af83d2ed6f6b430fbbbcdf3d92d4/href">https://medium.com/media/c2f8af83d2ed6f6b430fbbbcdf3d92d4/href</a></iframe><h4>Stages</h4><p>A seção <strong>stages</strong> permite gerar diferentes estágios em seu pipeline que serão visualizados como segmentos diferentes quando a tarefa for executada.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/440cb33a28afdd1dc7f32e39956789cd/href">https://medium.com/media/440cb33a28afdd1dc7f32e39956789cd/href</a></iframe><h4>Stage e Steps</h4><p>Pelo menos uma seção <strong>stage</strong> deve ser definida na seção <strong>stages</strong>. Dentro desse estágio estarão as instruções que o pipeline executará. Os estágios devem ser nomeados, pois o Jenkins exibirá cada um deles em Stage View.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*arR4KiqbQZLKTnx67A3gFg.png" /><figcaption>Stage View</figcaption></figure><p>A seção <strong>steps</strong> está contida dentro do bloco <strong>stage</strong>, e define uma série de uma ou mais etapas a serem executadas em uma determinada diretiva de estágio.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/63f3c4edaa6eff5fdd3314c20e4a4004/href">https://medium.com/media/63f3c4edaa6eff5fdd3314c20e4a4004/href</a></iframe><h4>Post</h4><p>A seções Post define uma ou mais etapas adicionais que são executadas após a conclusão de uma execução de pipeline ou estágio (dependendo do local da seção do post no pipeline). O post pode suportar qualquer um dos seguintes blocos de pós-condição: always, changed, fixed, regression, aborted, failure, success, unstable, unsuccessful, e cleanup. Esses blocos de condições permitem a execução de etapas dentro de cada condição, dependendo do status de conclusão do pipeline ou estágio.</p><p>Utilizaremos o bloco <strong>always</strong>, pois queremos que as etapas sejam executadas, independentemente do status de conclusão da execução do pipeline ou do estágio.</p><p>A estrutura final de nosso pipeline será a seguinte:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/51948e34b49ed91680d76de47a50b89d/href">https://medium.com/media/51948e34b49ed91680d76de47a50b89d/href</a></iframe><h3>Implementando os Steps em cada Stage</h3><p>Para implementar os setps você pode utilizar a opção <strong>Snippet Generator</strong> do próprio Jenkins, o que facilita na geração dos códigos.</p><h4>Checkout</h4><p>Nosso primeiro step será o <strong>Checkout</strong>, que irá fazer um <em>“git clone” </em>no repositório do nosso projeto no github:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f4c0382a18297266779d913ddd23d2fc/href">https://medium.com/media/f4c0382a18297266779d913ddd23d2fc/href</a></iframe><p>O comando <strong>slackSend</strong> será utilizado para enviar uma notificação no slack da equipe assim que o job for iniciado. Como parâmetros passaremos:</p><ul><li><strong>channel </strong>(canal do slack)</li><li><strong>color </strong>(cor do marcador da mensagem no slack)</li><li><strong>message</strong>(mensagem enviada no slack).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*6RkvtnmoYXvf32For_12mQ.png" /><figcaption>Notificação de Start no pipeline</figcaption></figure><p>Para fazer download do repositório, iremos usar o comando <strong>git</strong>, informando os parâmetros:</p><ul><li><strong>branch</strong> (branch escolhida)</li><li><strong>credentialsId</strong> (chave gerada pelo Snippet Generator<strong> </strong>do Jenkins)</li><li><strong>url</strong> (endereço do repositório no git).</li></ul><p>Após criar o estágio de checkout, podemos executar nosso pipeline, clicando em <strong>Build Now</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/1*3KIQ71KFURmu7ZFKf4PQIg.png" /></figure><p>Após a execução, a coluna <strong>Checkout</strong> será exibida no <strong>Stage View</strong> e, a cada execução com sucesso, será mostrada na cor verde:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*cA6wLiUDKZnbw0gD8aRMZQ.png" /></figure><h4>Testes Unitários</h4><p>Neste estágio do pipeline, iremos executar os testes unitários.</p><p>Como o projeto está escrito na linguagem Java, iremos usar o Maven para compilar e executar os testes com o comando <strong>sh </strong>(comando executado no shell) <strong>mvn clean test</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e31faaa40b94f957eb0e58fdedf395dd/href">https://medium.com/media/e31faaa40b94f957eb0e58fdedf395dd/href</a></iframe><p>Depois de adicionarmos o estágio de testes unitários, podemos executar nosso pipeline, clicando novamente em <strong>Build Now</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*Zn14smwrWfRdY_0DkIg-xw.png" /></figure><p>Note que agora uma nova coluna de testes unitários foi adicionada ao <strong>Stage View</strong>.</p><h4>Relatórios de Code Coverage</h4><p>Para armazenar e publicar os relatórios testes unitários no Jenkins utilizaremos os comandos <strong>publishHTML</strong>, indicando os parâmetros:</p><ul><li><strong>reportDir </strong>(diretório onde o relatório do jacoco é armazenado)</li><li><strong>reportFiles </strong>(arquivo de relatório)</li><li><strong>reportName </strong>(nome do relatório)</li><li><strong>testResults </strong>(arquivo de resultados de teste)</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/27826737ad0974faf59495efd49f603b/href">https://medium.com/media/27826737ad0974faf59495efd49f603b/href</a></iframe><p>Após executarmos nosso pipeline novamente, a coluna de arquivamento de relatórios será exibida no <strong>Stage View</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*KiWTWUenLLdMyA9WngVWHw.png" /></figure><p>Agora será exibido um gráfico que nos possibilita uma visualização rápida sobre falhas/sucesso de testes unitários.</p><p>Para acessar os relatórios detalhados de cobertura de testes, selecione a opção <strong>Code Coverage</strong> no menu lateral esquerdo:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mhxj1O7DsnNktQtlaG47pA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6_kILOvQhMo1MIuM7NsgMQ.png" /><figcaption>Code Coverage Report</figcaption></figure><h4>Execução de testes de integração</h4><p>Podemos executar neste mesmo pipeline os testes integrados. Neste caso, os testes automatizados desenvolvidos pelos QAs da equipe estão armazenados em um repositório diferente do repositório de código dos Desenvolvedores. Faremos então o download do nosso repositório de testes integrados usando o comando <strong>git</strong> novamente, mas dessa vez indicando o repositório da equipe de QA.</p><p>Para executar os testes do cucumber utilizaremos o comando <strong>sh </strong>(comando executado no shell) <strong>mvn clean install</strong>.</p><p>O comando cucumber será utilizado para gerar os relatórios dos cenários de teste do BDD, através do plugin <strong>Cucumber Reports</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d65639df7876fdc539b7b3de39554ff1/href">https://medium.com/media/d65639df7876fdc539b7b3de39554ff1/href</a></iframe><p>Após executarmos novamente nosso pipeline, no <strong>Stage View</strong> teremos uma nova coluna referente aos testes integrados:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*zDXPnPmFIewq7nvjIm4vfg.png" /></figure><p>Podemos visualizar os relatórios do cucumber clicando na opção <strong>Cucumber Reports</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/1*cBO-9yCuxvGIMK3jztMBMA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FVxwKWGcLwTtVt9kk5m8yw.png" /></figure><h4>Post script</h4><p>Para finalizar, executaremos o post script, para enviar uma mensagem de sucesso ou falha para o time no canal do slack a cada execução do pipeline.</p><p>Adicionaremos no parâmetro color o método <strong>COLOR_MAP</strong>, para que as cores sejam alteradas de acordo com o resultado.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b77418c22bfd66094ec5d1eec6c1927/href">https://medium.com/media/8b77418c22bfd66094ec5d1eec6c1927/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*87JdigzaKlcUXgiEOEBDsQ.png" /><figcaption>Notificação de sucesso no Slack</figcaption></figure><p>Executaremos novamente nosso pipeline e o último estágio de <strong>Post Actions </strong>será exibido:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*CdQlsyzDPgsETrOm5STHBQ.png" /></figure><h4>Configurando triggers</h4><p>Agora vamos para a parte mais legal do nosso pipeline. Aqui é onde dizemos ADEUS a todo aquele processo manual que citei no início deste post, e passamos a ser ágeis de verdade!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FxT0xeJpnrWC4XWblEk%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fwhoa-hd-tim-and-eric-xT0xeJpnrWC4XWblEk&amp;image=https%3A%2F%2Fmedia3.giphy.com%2Fmedia%2FxT0xeJpnrWC4XWblEk%2Fgiphy-downsized-large.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="289" frameborder="0" scrolling="no"><a href="https://medium.com/media/f4342f52c56314fcb70fc40650749795/href">https://medium.com/media/f4342f52c56314fcb70fc40650749795/href</a></iframe><p>O pipeline será executado AUTOMATICAMENTE a cada commit feito pelos desenvolvedores no código. Para que isso funcione devemos fazer a seguinte configuração em <strong>Configure</strong> &gt; <strong>Build Triggers</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*pi7QLSE9YPd8Jj-QA7bzEg.png" /></figure><p>Marcando a opção <strong>Poll SCM</strong> o Jenkins buscará novos commits no git, usando a técnica de polling. Em schedule será necessário indicar a frequência que serão feitas as tentativas. Devemos usar expressões de cron (<a href="https://crontab.guru/">https://crontab.guru/</a>).</p><h3>Versão final do script</h3><p>Para finalizar o passo a passo, temos nosso script completo:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/01b5d30c650ee842febd7661e0d0af3d/href">https://medium.com/media/01b5d30c650ee842febd7661e0d0af3d/href</a></iframe><blockquote>Finalmente temos nosso pipeline pronto!</blockquote><blockquote>Com os testes sendo executados em uma esteira, eliminamos a necessidade de executar nossa automação manualmente a cada incremento no código.</blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FxT0GqCd3OEQdXNdIME%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fferris-buellers-day-off-its-over-go-home-xT0GqCd3OEQdXNdIME&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FxT0GqCd3OEQdXNdIME%2F200.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="198" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c93f95258e83cff59bb6e550851c5d9/href">https://medium.com/media/7c93f95258e83cff59bb6e550851c5d9/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d84087963499" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>