diff options
| author | Franck Cuny <franck.cuny@gmail.com> | 2013-11-26 10:36:10 -0800 |
|---|---|---|
| committer | Franck Cuny <franck.cuny@gmail.com> | 2013-11-26 10:36:10 -0800 |
| commit | 8ddf2e94df70707b458528a437759b96046d3e01 (patch) | |
| tree | d442818d92d3c9c6f7fcdc92857a1228963849a1 /_posts/2009-05-06-a-simple-feed-aggregator-with-modern-perl-part-3.textile | |
| parent | Don't need to use the IP in the makefile. (diff) | |
| download | lumberjaph-8ddf2e94df70707b458528a437759b96046d3e01.tar.gz | |
Huge update.
Moved all posts from textile to markdown. Updated all the CSS and
styles. Added a new page for the resume.
Diffstat (limited to '')
| -rw-r--r-- | _posts/2009-05-06-a-simple-feed-aggregator-with-modern-perl-part-3.md (renamed from _posts/2009-05-06-a-simple-feed-aggregator-with-modern-perl-part-3.textile) | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/_posts/2009-05-06-a-simple-feed-aggregator-with-modern-perl-part-3.textile b/_posts/2009-05-06-a-simple-feed-aggregator-with-modern-perl-part-3.md index 3da3485..5f66675 100644 --- a/_posts/2009-05-06-a-simple-feed-aggregator-with-modern-perl-part-3.textile +++ b/_posts/2009-05-06-a-simple-feed-aggregator-with-modern-perl-part-3.md @@ -1,17 +1,17 @@ --- layout: post title: A simple feed aggregator with modern Perl - part 3 -category: perl +summary: In which we continue to write our feed aggregator. --- -Now that we have our aggregator, we have to write our tests. For this I will use Test::Class. Ovid have wrote an "excellent":http://www.modernperlbooks.com/mt/2009/03/organizing-test-suites-with-testclass.html "serie":http://www.modernperlbooks.com/mt/2009/03/reusing-test-code-with-testclass.html "of":http://www.modernperlbooks.com/mt/2009/03/making-your-testing-life-easier.html "articles":http://www.modernperlbooks.com/mt/2009/03/using-test-control-methods-with-testclass.html "about Test::Class":http://www.modernperlbooks.com/mt/2009/03/working-with-testclass-test-suites.html. You should really read this, because I will not enter in details. +Now that we have our aggregator, we have to write our tests. For this I will use Test::Class. Ovid have wrote an [excellent](http://www.modernperlbooks.com/mt/2009/03/organizing-test-suites-with-testclass.html) [serie](http://www.modernperlbooks.com/mt/2009/03/reusing-test-code-with-testclass.html) [of](http://www.modernperlbooks.com/mt/2009/03/making-your-testing-life-easier.html) [articles](http://www.modernperlbooks.com/mt/2009/03/using-test-control-methods-with-testclass.html) [about Test::Class](http://www.modernperlbooks.com/mt/2009/03/working-with-testclass-test-suites.html). You should really read this, because I will not enter in details. We have two things to test: * roles * aggregator -h3. Roles +### Roles For this, we create the following files: @@ -20,7 +20,7 @@ For this, we create the following files: * t/tests/Test/MyAggregator.pm * t/run.t -We will write our *run.t*: +We will write our **run.t**: {% highlight perl %} use lib 't/test'; @@ -99,21 +99,19 @@ Now we have to tests our 2 methods from the roles. We will test the fetch_feed m First, we indicate the number of tests that will be executed (6 in our case). Then we can write the test in the method: - * create an object - * fetch an url, and test the HTTP code of the response - * check if the content look like something we want - * now the data should be in cache, and the a new fetch of the url should return a 304 HTTP code +* create an object +* fetch an url, and test the HTTP code of the response +* check if the content look like something we want +* now the data should be in cache, and the a new fetch of the url should return a 304 HTTP code The second method to test is feed_parser. This method will do 3 tests. - * create an object - * we manually fetch the content from a feed - * send this content to feed_parser - * the result should return a XML::Feed::Format::RSS object +* create an object +* we manually fetch the content from a feed +* send this content to feed_parser +* the result should return a XML::Feed::Format::RSS object -When you run the tests now - -bc. prove t/run.t +When you run the tests now `prove t/run.t` the following result is produced: @@ -143,16 +141,15 @@ Files=1, Tests=11, 3 wallclock secs ( 0.03 usr 0.01 sys + 0.66 cusr 0.09 csy Result: PAS {% endhighlight %} -h3. Aggregator +### Aggregator -As we have our tests for the roles, we can write the tests for the -aggregator now. First, we add a new line in *t/run.t* +As we have our tests for the roles, we can write the tests for the aggregator now. First, we add a new line in **t/run.t**. {% highlight perl %} use Test::MyAggregator {% endhighlight %} -We edit our *t/tests/Test/MyAggregator.pm*: +We edit our **t/tests/Test/MyAggregator.pm**: {% highlight perl %} package Test::MyAggregator; @@ -259,4 +256,4 @@ Files=1, Tests=9, 3 wallclock secs ( 0.01 usr 0.01 sys + 1.39 cusr 0.12 csys Result: PASS {% endhighlight %} -We have our tests, so next step is the Catalyst frontend. As for the precedents parts, "the code is available on github":http://github.com/franckcuny/ironman-myaggregator/tree/master +We have our tests, so next step is the Catalyst frontend. As for the precedents parts, [the code is available on GitHub](http://github.com/franckcuny/ironman-myaggregator/tree/master) |
