Software testing - does Prolog need it?

Showing 1-4 of 4 messages
Software testing - does Prolog need it? tbra...@google.com 10/14/13 8:28 AM
Most software tests look like the Prolog code you actually run.

Is it necessary to write tests for Prolog/logic programs?
Re: Software testing - does Prolog need it? Jan Burse 10/14/13 10:38 AM
tbra...@google.com schrieb:
> Most software tests look like the Prolog code you actually run.

I don't understand what you mean by that. Could
you elaborate? Do you mean using Prolog to test
Prolog? You find the same in JUnit, using Java
to test Java.

The Prolog tests Prolog works, if the test start/end
points are easily accessible by Prolog. This is
typically the case for unit tests, but could be
harder for system tests and/or integration tests.

For unit tests there are even frameworks around
that help you in test. See for example:

Prolog Unit Tests
http://www.swi-prolog.org/pldoc/package/plunit.html

> Is it necessary to write tests for Prolog/logic programs?

I guess it is not necessary, but if you don't have
a formal verification for your logic program, then
tests can serve as an empirical validation of your
logic program.

Actually I would like to see a web test framework,
written in Prolog, something along:

http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks#Internet

Something that can handle a conversation, and probe
and fill web pages. Although if the testing framework
is written in Prolog it could nevertheless run test
cases against any web application not necessarely
written in Prolog.

Bye

Re: Software testing - does Prolog need it? Ulrich Neumerkel 10/15/13 3:19 AM
tbra...@google.com writes:
>Most software tests look like the Prolog code you actually run.
>
>Is it necessary to write tests for Prolog/logic programs?

Any code written in a programming or specification language
needs some more concrete cases or properties stated, simply
such that people can understand it with concrete examples
and compare it to requirements.

Re: Software testing - does Prolog need it? Joachim Schimpf 10/16/13 6:13 AM
On 14/10/2013 16:28, tbra...@google.com wrote:
> Most software tests look like the Prolog code you actually run.
>
> Is it necessary to write tests for Prolog/logic programs?

It is true that a properly written Prolog program can be used as a test.

In practice, that means you can run the program once to compute a result,
and then run it again to verify the result.  Obviously, the benefit you get
from this kind of test is limited -- after all, if your program is buggy,
you use the same buggy program for testing.  Having said that, executing the
Prolog program in "test mode" (i.e. with all variables already instantiated
to their solutions) may well lead to different control flow in the Prolog
code, so that it is indeed possible to catch a few errors with this method.

This technique is actually more useful for Constraint Logic Programming (CLP),
where the programs tend to be simpler (i.e. more declarative, more test-like).
There, the execution algorithms used in "solving-mode" can be extremely complex,
while running the same program as a test is computationally trivial.

The shortcoming of such a test is of course that you use the same specification
for both computing and testing, i.e. you won't catch errors in the specification.
To do so, you need separate tests that use a different problem formulation, or
explicitly check for conditions that are merely implicit in the program.

The other issue is that you a need a manageable, finite number of concrete
test cases, out of the potentially infinite number of possible call patterns.
Some of these could be generated automatically from the program, I'm pretty
sure that research has been done in this direction.

Cheers,
Joachim