<?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>The Turning Point &#187; Tests</title>
	<atom:link href="http://blog.franktrindade.com/category/tests/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.franktrindade.com</link>
	<description>Agile, software and some nonsense</description>
	<lastBuildDate>Tue, 31 Jan 2012 21:30:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Page Model with Cucumber and Capybara</title>
		<link>http://blog.franktrindade.com/2011/03/04/page-model-with-cucumber-and-capybara/</link>
		<comments>http://blog.franktrindade.com/2011/03/04/page-model-with-cucumber-and-capybara/#comments</comments>
		<pubDate>Fri, 04 Mar 2011 20:59:31 +0000</pubDate>
		<dc:creator>franktrindade</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[Tests]]></category>
		<category><![CDATA[capybara]]></category>
		<category><![CDATA[cucumber]]></category>

		<guid isPermaLink="false">http://blog.franktrindade.com/?p=516</guid>
		<description><![CDATA[I&#8217;ve spent some time today changing the Cucumber/Capybara tests in one of my pet projects to use a page model. Since I didn&#8217;t find much stuff on the interwebs about it, why not write it here ? The idea behind having a page model is to keep steps related to a specific page on your [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve spent some time today changing the Cucumber/Capybara tests in one of my pet projects to use a page model. Since I didn&#8217;t find much stuff on the interwebs about it, why not write it here ?</p>
<p>The idea behind having a page model is to keep steps related to a specific page on your app in the same place, so you can reduce the repetition of steps in different tests. Is definitely not a complicated practice, and setting Capybara for it is a simple step.</p>
<p>Setting the context, Im using Cucumber 0.10 with Capybara 0.4.1.2 and Rails 3.0.1. Have done the standard installation steps recommended by the <a href="https://github.com/aslakhellesoy/cucumber-rails">cucumber-rails github page</a>.</p>
<p>The only modification I&#8217;ve made with the created structure is adding a folder for the page objects, so the final structure is this:</p>
<p><a rel="attachment wp-att-519" href="http://blog.franktrindade.com/2011/03/04/page-model-with-cucumber-and-capybara/screen-shot-2011-03-05-at-2-00-31-am/"><img class="alignnone size-full wp-image-519" title="Screen shot 2011-03-05 at 2.00.31 AM" src="http://blog.franktrindade.com/wp-content/uploads/2011/03/Screen-shot-2011-03-05-at-2.00.31-AM.png" alt="" width="219" height="162" /></a></p>
<p>As you can see, inside the pages folder there is a home page file, which is responsible for every action/assertion related to the home page.</p>
<p>Nothing new with the cucumber features, which keep having it&#8217;s standard style</p>
<p><code>Feature: Manage tasks<br />
In order to manage my tasks,<br />
a user<br />
wants to create tasks in different categories</p>
<p>Scenario: Create a new task<br />
Given I am in the Do Me home page<br />
When I create an urgent and important task with description "my task"<br />
Then I should see "my task" in the "Urgent and Important" section<br />
</code></p>
<p>However, in order to create our page object, we need to inject the test driver on it, which in Capybara&#8217;s case, is the session object.</p>
<p><code>Given /^I am in the home page$/ do<br />
@home_page = HomePage.new(Capybara.current_session)<br />
@home_page.visit<br />
end</p>
<p>When /^I create an urgent and important task with description "([^"]*)"$/ do |task_description|<br />
@home_page.fill_task_description(task_description)<br />
@home_page.check_important<br />
@home_page.check_urgent<br />
@home_page.create_task<br />
end</code></p>
<p>And from there is just the trouble of creating the page class (or do like me, who shamelessly copied the style from <a href="http://watirmelon.com/2011/01/21/my-simple-cucumber-watir-page-object-pattern-framework/">here</a>).</p>
<p><code><br />
class HomePage<br />
</code</p>
<p><code><br />
URL = "/"</p>
<p>def initialize(session)<br />
@session = session<br />
end</p>
<p>def visit<br />
@session.visit URL<br />
end</p>
<p>def fill_task_description(description)<br />
@session.fill_in("Description", :with =&gt; description)<br />
end</p>
<p>def check_urgent<br />
check("Urgent")<br />
end</p>
<p>def check_important<br />
check("Important")<br />
end</p>
<p>def create_task<br />
@session.click_button("Create Task")<br />
end<br />
</code></p>
<p>And that&#8217;s pretty much it, now is just choosing your preferred driver and run the tests. As you can see, not much effort for a nice improvement.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.franktrindade.com/2011/03/04/page-model-with-cucumber-and-capybara/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Behaviour Driven Development</title>
		<link>http://blog.franktrindade.com/2008/02/20/behaviour-driven-development/</link>
		<comments>http://blog.franktrindade.com/2008/02/20/behaviour-driven-development/#comments</comments>
		<pubDate>Wed, 20 Feb 2008 15:22:40 +0000</pubDate>
		<dc:creator>franktrindade</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Portuguese]]></category>
		<category><![CDATA[Tests]]></category>
		<category><![CDATA[Bdd]]></category>
		<category><![CDATA[thoughtworks]]></category>

		<guid isPermaLink="false">http://franktrindade.wordpress.com/?p=23</guid>
		<description><![CDATA[Para os que não sabem, atualmente eu estou em Bangalore, na Índia, participando do treinamento que a Thoughtworks oferece aos seus novos graduates, a ThoughtWorks University. Bom, ontem, depois de assistir a uma sessão opcional do curso, apresentada pela Liz Keogh, eu finalmente posso dizer que entendo o que é Behaviour Driven Development, o famoso [...]]]></description>
			<content:encoded><![CDATA[<p>Para os que não sabem, atualmente eu estou em Bangalore, na Índia, participando do treinamento que a Thoughtworks oferece aos seus novos <i>graduates, </i>a ThoughtWorks University.</p>
<p>Bom, ontem, depois de assistir a uma sessão opcional do curso, apresentada pela <a href="http://sirenian.livejournal.com/" title="Blog Liz Keogh" target="_blank">Liz Keogh</a>, eu finalmente posso dizer que entendo o que é Behaviour Driven Development, o famoso <a href="http://en.wikipedia.org/wiki/Behavior_driven_development" title="BDD - Wikipedia" target="_blank">BDD</a>.  Essa é uma das <i>buzzwords</i> do mundo do software que circula ha algum tempo, mas devo confessar que nunca consegui parar para verificar o que era, e sempre imaginei que fosse mais uma metodologia ágil, tipo o <a href="http://en.wikipedia.org/wiki/Feature_Driven_Development" title="FDD - Wikipedia" target="_blank">FDD</a>.</p>
<p>Acontece que o Behaviour Driven Development é algo talvez até mais simples, mas nao por isso menos interessante :-) .</p>
<p>BDD nada mais é do que uma &#8220;otimização&#8221; do desenvolvimento orientado a testes, que tem como sua principal característica, e ainda mais importante, benefício, o fato de codificar as aplicações em uma linguagem voltada para o que é mais importante e muitas vezes esquecido, <b>o resultado que a aplicação tem para o cliente</b>.</p>
<p>Olhando por aí, uma justificativa interessante que eu achei foi a seguinte, no blog do <a href="http://dannorth.net/2008/02/goal-oriented-vocabulary" title="Dan North" target="_blank">Dan North</a>:</p>
<p><i>As a final thought, while I was thinking about this I realised the term “behaviour-driven” contrasts with “test-driven” in a similar way. My <i>goal</i> as a developer is to deliver a system that behaves in a particular way. Whether or not it has tests is an interesting metric, but not the core purpose. “Test-driven” development will cause me to have lots of tests, but it won’t necessarily get me nearer the goal of delivering business value through software. So you can use goal-oriented vocabulary in your development process as well as your code to help maintain perspective on what you are trying to achieve.</i></p>
<p>Já que todos (todos?) concordamos que entregar valor de negócio para o que cliente é o que realmente importa no desenvolvimento de uma aplicação, porque não desenvolver essa aplicação de acordo com a linguagem do cliente, de forma que até ele possa entender (mesmo que em um nível básico) o que a aplicação está fazendo, e para que serve aquele código.</p>
<p>É claro que não é só esse o benefício, já que muitos de vcs devem estar pensando: <i>para que diabos o meu cliente que ver o código-fonte do software?</i></p>
<p>Mas desenvolver código-fonte de acordo com a linguagem do negócio também auxilia o desenvolvedor a entender e discutir as funcionalidades que ele está desenvolvendo, e realmente saber qual é o objetivo de ele sentar na frente do computador 8 horas por dia, o que invariavelmente resulta em código de melhor qualidade.</p>
<p>Comentários?</p>
<p>Um abraço.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.franktrindade.com/2008/02/20/behaviour-driven-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

