Menu:

Post History:

Animals Matter to Me

Installing PlUnit on Ubuntu

Only a short update to the chain tonight because its getting late.

Before starting on the Prolog code for the prologblog.com site, I wanted to see if anyone in the Prolog community had documented how to do Test Driven Development (TDD) or Behavior Driven Development (BDD) in Prolog. I couldn’t even find some discussion on the subject let alone a how-to or tool set. For now, I will be on my own and figuring it out as I go.

The testing framework included with SWI-Prolog is called PlUnit. The Ubuntu SWI packages caused me to waste some more time today, as they don’t seem to include PlUnit, despite it being a package normally distributed with SWI. To use it, I had to get the current version directly from the SWI git respository. I kept the Ubuntu package-installed version of SWI and was able to manually install PlUnit next to it. Here are the steps for doing that.

Clone the SWI-Prolog git repository

git clone git://prolog.cs.vu.nl/home/pl/git/pl.git

Configure and install PlUnit

cd pl/packages/plunit
autoconf
./configure
sudo make install

Note that there is no actual ‘make’ step. There is nothing to build, the files just need to be copied into the correct location.

Check installation

To check that it was installed properly, one can run the files from the PlUnit examples directory.

cd pl/packages/plunit/examples/ # in the cloned git repo
swipl -g "[simple],run_tests,halt."
 % simple compiled into ex_simple 0.01 sec, 108,664 bytes
 % PL-Unit: lists ........ done
 % All 8 tests passed

2 comments


nicholas a. evans on March 16, 2009 9:50AM

FWIW, you could write higher level acceptance tests in cucumber and webrat... so long as that doesn't feel like cheating to leave the prolog world or too much yakshaving/reinventing-the-wheel to write a mini-cucumber-like-framework and webrat-like-library in prolog. But reinvention of said wheels would make for good blog posts. :) e.g. http://github.com/kesor/p5-cucumber/tree/master

Jeff Dallien on March 16, 2009 2:07PM

I don't think having something cucumber-like done in Prolog would be reinventing the wheel, since all the testing options seem to be either PlUnit or something very close. This is probably because its pretty easy to write one in that style, any bit of Prolog code will report a pass/fail when run because that's just the way Prolog is. I haven't seen anything available with a descriptive, step-by-step component like cucumber, so I think I will attempt to write one at some point.

Add Comment

*
(not shown)
*

* Code: simple_captcha.jpg
* required