<?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>Sukria.net &#187; Test</title>
	<atom:link href="http://www.sukria.net/fr/archives/tag/test/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sukria.net/fr</link>
	<description>Alexis Sukrieh&#039;s blog, mostly Perl stuff</description>
	<lastBuildDate>Fri, 27 Aug 2010 13:33:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Thoughts about an easy-to-use Mocker for Perl</title>
		<link>http://www.sukria.net/fr/archives/2009/09/11/thoughts-about-an-easy-to-use-mocker-for-perl/</link>
		<comments>http://www.sukria.net/fr/archives/2009/09/11/thoughts-about-an-easy-to-use-mocker-for-perl/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 18:22:46 +0000</pubDate>
		<dc:creator>sukria</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Mock]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Test]]></category>

		<guid isPermaLink="false">http://www.sukria.net/fr/?p=1237</guid>
		<description><![CDATA[Unit-testing is the way to go in modern programing. When you&#8217;re at writing unit tests, chances are that you will eventually need the so-called mock objects. You can find a pretty good definition of Mock objects here. In Perl, writing &#8230; <a href="http://www.sukria.net/fr/archives/2009/09/11/thoughts-about-an-easy-to-use-mocker-for-perl/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Unit-testing is the way to go in modern programing. When you&#8217;re at writing unit tests, chances are that you will eventually need the so-called <em>mock objects</em>.</p>
<p>You can find a pretty good definition of Mock objects <a href="http://martinfowler.com/articles/mocksArentStubs.html">here</a>. In Perl, writing Mocks can be done with <a href="http://search.cpan.org/dist/Test-MockClass/">Test::MockClass</a> and <a href="http://search.cpan.org/dist/Test-MockObject/">Test::MockObject</a> which are pretty complete modules for that purpose.</p>
<p>However, I&#8217;ve came to <a href="http://gugod.org/">gugod&#8217;s blog</a> and found out his post about <a href="http://gugod.org/2009/05/mocking.html">Mocking in Perl</a>. I like his post and find his conclusion pertinent:</p>
<blockquote><p>
However, I still want my test program reads as simple as the rspec statement, it reads better. The most important of all, you don’t really need to know the whole pros and cons and the concept of “Mocking” to do it.
</p></blockquote>
<p>Hence I&#8217;ve been thinking at a module who could be named Test::Mocker &#8211; or even Test::EasyMocker &#8211; and who will be usable like the following.</p>
<pre class="prettyprint">
use Test::Mocker 'Player';

Player->should( run => 42);
</pre>
<p>We could also imagine a more complex mock with a sub instead of a constant value:</p>
<pre class="prettyprint">
use Test::Mocker 'Player';

Player->should( run => sub { return 42; });
</pre>
<p>As you can see, when importing Test::Mocker, we give it a list of packages we intend to mock in the test, that provides them with the &#8220;should&#8221; static method.</p>
<p>I like the ease of use of that syntax and find it pretty natural to write; I&#8217;d be happy to read your comments on this.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sukria.net/fr/archives/2009/09/11/thoughts-about-an-easy-to-use-mocker-for-perl/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Test::WWW::Mechanize::Runner est publié</title>
		<link>http://www.sukria.net/fr/archives/2007/12/19/testwwwmechanizerunner-est-publie/</link>
		<comments>http://www.sukria.net/fr/archives/2007/12/19/testwwwmechanizerunner-est-publie/#comments</comments>
		<pubDate>Wed, 19 Dec 2007 20:36:11 +0000</pubDate>
		<dc:creator>sukria</dc:creator>
				<category><![CDATA[Programmation]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Test]]></category>

		<guid isPermaLink="false">http://www.sukria.net/fr/archives/2007/12/19/testwwwmechanizerunner-est-publie/</guid>
		<description><![CDATA[Comme expliqué ici, Test::WWW::Mecanize::Runner est publié.]]></description>
			<content:encoded><![CDATA[<p>Comme expliqué <a href="http://www.sukria.net/en/archives/2007/12/19/write-functionnal-test-suites-for-webapps-with-testwwwmechanizerunner/">ici</a>, <a href="http://search.cpan.org/~sukria/Test-WWW-Mechanize-Runner-0.0.1/lib/Test/WWW/Mechanize/Runner.pm">Test::WWW::Mecanize::Runner</a> est publié.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sukria.net/fr/archives/2007/12/19/testwwwmechanizerunner-est-publie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tester des applications Web avec Perl</title>
		<link>http://www.sukria.net/fr/archives/2007/12/18/tester-des-applications-web-avec-perl/</link>
		<comments>http://www.sukria.net/fr/archives/2007/12/18/tester-des-applications-web-avec-perl/#comments</comments>
		<pubDate>Tue, 18 Dec 2007 17:29:33 +0000</pubDate>
		<dc:creator>sukria</dc:creator>
				<category><![CDATA[Programmation]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Test]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.sukria.net/fr/archives/2007/12/18/tester-des-applications-web-avec-perl/</guid>
		<description><![CDATA[Après avoir fouillé un peu pour voir ce qui se fait en matière de tests fonctionnels pour les applications Web, je suis tombé sur la combo qui tue : WWW::Mechanize pour scripter un surf HTTP::Recorder pour enregistrer un scénario en &#8230; <a href="http://www.sukria.net/fr/archives/2007/12/18/tester-des-applications-web-avec-perl/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Après avoir fouillé un peu pour voir ce qui se fait en matière de tests fonctionnels pour les applications Web, je suis tombé sur la combo qui tue : </p>
<ul>
<li><a href="http://search.cpan.org/perldoc?WWW::Mechanize">WWW::Mechanize</a> pour scripter un surf</li>
<li><a href="http://search.cpan.org/perldoc?HTTP::Recorder">HTTP::Recorder</a> pour enregistrer un scénario en live au format WWW::Mechanize (via un proxy local)</li>
<li><a href="http://search.cpan.org/perldoc?Mozilla::Mechanize">Mozilla::Mechanize</a> pour jouer le script WWW::Mechanize en pilotant Mozilla (via xulrunner)</li>
<li><a href="http://search.cpan.org/perldoc?Win32::IE::Mechanize">Win32::IE::Mechanize</a> pour faire de même avec IE en environnement Win32.</li>
</ul>
<p>Il manquait à mon gout juste une chose : un wrapper qui vous permette d&#8217;écrire un scénario sans se soucier de l&#8217;agent à utiliser (WWW, Mozilla ou IE). En effet, ça serait vraiment dommage d&#8217;avoir à écrire autant de scénario qu&#8217;on a d&#8217;environnement à tester.<br />
<a href="http://svn.sukria.net/filedetails.php?repname=Alexis+Sukrieh%27s+SVN+Rpository&#038;path=%2FTest-WWW-Mechanize-Runner%2Flib%2FTest%2FWWW%2FMechanize%2FRunner.pm&#038;rev=0&#038;sc=0"><br />
J&#8217;ai donc écrit un petit wrapper</a> pour écrire une suite de test qui joue un scénario avec l&#8217;agent que l&#8217;on souhaite.</p>
<p>Globalement ça marche comme ça : </p>
<ol>
<li>on écrit le scéario qui nous plait dans un module qui hérite de Test::WWW::Mechanize::Runner dans des &#8220;suites&#8221;
<pre>
package MonScenario;
use Test::WWW::Mechanize::Runner;
use base 'Test::WWW::Mechanize::Runner';

suite load_google => sub {
    my ($agent) = @_;

    ok($agent->get('http://www.google.fr'),
        'GET http://www.google.fr');
};
</pre>
</li>
<li>le fichier de test ne comprend que 3 lignes et ressemble à ça (pour un jeu avec Mozilla::Mechanize) :
<pre>
use MonScenario;
MonScenario->init('mozilla');
MonScenario->run();
</pre>
</li>
</ol>
<p>Bientôt sur le CPAN&#8230;</p>
<p>PS : bon, il y a un soucis de compilation pour Mozilla::DOM (une dépendance de Mozilla::Mechanize) sur Debian (il cherche à utiliser le xpcom de mozilla alors que debian oblige à passer par xulrunner) ; le patch est simple, <strike>je compte le soumettre dans le BTS du CPAN</strike> <a href="http://rt.cpan.org/Ticket/Display.html?id=31683">je l&#8217;ai soumis sur le BTS du module</a>, et si je trouve une demi-heure quelque part, à packager libmozilla-mechanize-perl.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sukria.net/fr/archives/2007/12/18/tester-des-applications-web-avec-perl/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
