Skip to content

Idea: override plunit:test/1 to provide better feedback #43

@simonharris

Description

@simonharris

In many cases, where something simply "didn't work", eg:

test(difference_unicorn) :-
    Sentence = [the, second, and, fourth, differ, by, a, unicorn],
    atoms_clue(Sentence, Clue).

plunit gives us:

[32/88] parser:difference_unicorn .................................................................................................................... **FAILED (0.000 sec)
ERROR: /Users/simon/project_git/safecracker.pl/api/prolog/tests/test_parser.pl:90:
ERROR:     test parser:difference_unicorn: failed

This is before plunit_assert even gets involved. A test_with_enhanced_feedback/1 would be a nice idea, but plunit wouldn't call it (I assume it looks only for test/1, rather than test*. Check this.)

As it stands, the library actually temporarily "replaces" prolog:assertion_failed and user:message_hook, intercepts the output, and then restores them as if nothing happened. What if we did the same for test/1? (I assume it'd be something like plunit:test in fact). Then our code could try to do a bit of Miss Marple on what went wrong, and give better feedback, before silently restoring test/1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions