[m-users.] Basic Unit Test Framework

Dirk Ziegemeyer dirk at ziegemeyer.de
Tue Jul 14 07:49:39 AEST 2015


> Am 12.07.2015 um 22:37 schrieb Charles Shuller <charles.shuller at gmail.com>:
> 
> 2)  I handle a small number of test dispositions, not just PASS or FAIL, because I used to be a QA engineer and test management turns into a nightmare if you only have pass/fail on any project of scale.  The added dispositions include some to indicate that a test cannot be run on a platform (or for a particular grade in mercury's case), has not been run for whatever reason, finds a bug that isn't going to be fixed, or something that should be broken starts working again.

That makes sense to me.

> 3) Hard to get a message about what failed if the predicate only succeeds of fails.  I save off results instead of pushing IO into the test harness though.   I felt it made more sense.

I also don’t like pushing IO through the test cases, but I didn’t accomplish to put test cases into a list. After reading in the reference manual section 8.3, that higher-order terms can cause problems in polymorphic collection types, I gave up my try to collect test cases in a list.

> Did you find any solutions to the problems I encountered, or is it just that our solutions target two different use cases :)

For a simple XML parser, I wrote dozens of test cases like these:

%% testDCG(TestNo, DCG-predicate, InputToBeParsed, ExpectedResult, !IO)

testDCG(1, nameStartChar, ":", yes(':'), !IO),
testDCG(2, nameStartChar, "-", no, !IO),
testDCG(3, nameChar, "-", yes('-'), !IO),
testDCG(4, name, "Name", yes("Name"), !IO),
testDCG(5, attValue, "\"AttValue\"", yes("AttValue"), !IO),
testDCG(6, attribute, "attribute=\"Value\"",
    yes({"attribute", "Value"}), !IO),
…

I don’t understand the syntax of test_case yet. Could you please give me an example, how I can write a list of test cases for different DCG predicates?


Cheers,

Dirk




More information about the users mailing list