The Artima Developer Community
Sponsored Link

Java Buzz Forum
Mock frameworks in Perl

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Chris Winters

Posts: 931
Nickname: cwinters
Registered: Jul, 2003

Daytime: Java hacker; nighttime: Perl hacker; sleeptime: some of both.
Mock frameworks in Perl Posted: Jan 11, 2004 12:09 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Chris Winters.
Original Post: Mock frameworks in Perl
Feed Title: cwinters.com
Feed URL: http://www.cwinters.com/search/registrar.php?domain=jroller.com®istrar=sedopark
Feed Description: Chris Winters on Java, programming and technology, usually in that order.
Latest Java Buzz Posts
Latest Java Buzz Posts by Chris Winters
Latest Posts From cwinters.com

Advertisement
I recently posted a message to the dbi-dev mailing list about a mock DBD implementation. This is different than the dynamically mocked database handle chomatic discussed in his real-world example of Test::MockObject. There he replaced a package variable with a dynamic mock that would do what he wanted.

I need something different - a DBD implementation that DBI will load (when calling connect()) and act just like a normal driver, like those for Postgres or MySQL. This makes it possible to use your properly decoupled configuration to specify your mock implementation. For example, the initial declaration might look like:

 <persister name="TestPersister"
              class="Workflow::Persister::DBI"
              dsn="DBI:Pg:dbname=ticket"
              user="test"
              password="test"/>

So in your tests you have the option of using an in-memory or file-based database (like SQLite) and actually execute statements against it. But this creates an additional dependency which I'd rather not do. Another option is to replace the configuration with something like:

 <persister name="TestPersister"
              class="Workflow::Persister::DBI"
              dsn="DBI:Mock:"/>

And all your plumbing will Just Work. Then you can ask the plumbing if what you expected to happen happened (ask it about the SQL statements and bound parameters, for instance) and make that the foundation of some excellent tests. That's the goal of mock implementations like these. And AFAIK this is an area where Perl lags behind Java, which has a number of implementations in the Mock Objects framework to represent servlets, EJB containers, JDBC connections, resultsets, statements and the like. Hopefully we can pick up some slack and make it easier to test this stuff.

Read: Mock frameworks in Perl

Topic: SSH for Series 60! Previous Topic   Next Topic Topic: Bloggers google bomb George Bush

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use