# Run\_tests forall output

**URL:** <https://swi-prolog.discourse.group/t/run-tests-forall-output/8570>\
**Category:** General\
**Created:** [October 31, 2024, 6:09am UTC](https://swi-prolog.discourse.group/t/run-tests-forall-output/8570 "2024-10-31T06:09:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tatut](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/tatut/32/5300_2.png) [@tatut](https://swi-prolog.discourse.group/u/tatut)\
**Post date:** [October 31, 2024, 6:09am UTC](https://swi-prolog.discourse.group/t/run-tests-forall-output/8570/1 "2024-10-31T06:09:04Z")

</div>

Is there a way to make forall tests show a diff or even just the bindings.

For example I have the following module:

```prolog
:- module(sample,[]).

foo("x", 1).
foo("y", 2).
foo("z", 3).

:- begin_tests(sample).

f("x", 1).
f("q", 2).
f("y", 2).
f("z", 42).

test(all_foos, [forall(f(Name, Answer))]) :-
    foo(Name, Answer).

:- end_tests(sample).

```

when I run the tests I only get the number of the failure:

```prolog
?- run_tests(sample).
[1-2/1] sample:all_foos ........................ **FAILED (0.000 sec)
ERROR: /tmp/sample.pl:14:
ERROR: test sample:all_foos: failed
[1-4/1] sample:all_foos ........................ **FAILED (0.000 sec)
ERROR: /tmp/sample.pl:14:
ERROR: test sample:all_foos: failed
ERROR: 2 tests failed
% 2 tests passed
% Test run completed in 0.016 seconds (0.013 cpu)
false.

```

I need to manually count from source to see which test is the `[1-2/1]`.  
For a larger suite with many test cases, it would be better to see the actual `f(Name,Answer)` that failed.

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [October 31, 2024, 8:19am UTC](https://swi-prolog.discourse.group/t/run-tests-forall-output/8570/2 "2024-10-31T08:19:10Z")

</div>

Thanks. That was also the intend, but it was broken in the rewrite supporting concurrent testing. Fixed and changed the report to print the generator rather than just its variable values as you suggest. So, now I get

```prolog
109 ?- run_tests.
[1-2/1] sample:all_foos ........................ **FAILED (0.000 sec)
ERROR: /home/jan/src/swipl-devel/build.pgo/sample.pl:14:
ERROR: test sample:all_foos (2-th forall generator = f("q",2)): failed
[1-4/1] sample:all_foos ........................ **FAILED (0.000 sec)
ERROR: /home/jan/src/swipl-devel/build.pgo/sample.pl:14:
ERROR: test sample:all_foos (4-th forall generator = f("z",42)): failed
ERROR: 2 tests failed
% 2 tests passed
% Test run completed in 0.001 seconds (0.001 cpu)
false.

```

---

<div class="post-metadata">

**Author:** ![tatut](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/tatut/32/5300_2.png) [@tatut](https://swi-prolog.discourse.group/u/tatut)\
**Post date:** [October 31, 2024, 8:57am UTC](https://swi-prolog.discourse.group/t/run-tests-forall-output/8570/3 "2024-10-31T08:57:20Z")

</div>

That’s great!

Thanks for the quick reply, can’t wait to try it.

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [October 31, 2024, 8:59am UTC](https://swi-prolog.discourse.group/t/run-tests-forall-output/8570/4 "2024-10-31T08:59:28Z")

</div>

> [@tatut](#):
>
> can’t wait to try it.

Install from GIT 🙂 Or just fetch `plunit.pl` from the git source and put it into your library.

---

<div class="post-metadata">

**Author:** ![tatut](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/tatut/32/5300_2.png) [@tatut](https://swi-prolog.discourse.group/u/tatut)\
**Post date:** [October 31, 2024, 9:17am UTC](https://swi-prolog.discourse.group/t/run-tests-forall-output/8570/5 "2024-10-31T09:17:52Z")

</div>

Pulled plunit.pl from git, works great 👍

---

<div class="post-metadata">

**Author:** ![kwon-young](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/kwon-young/32/4841_2.png) [@kwon-young](https://swi-prolog.discourse.group/u/kwon-young)\
**Post date:** [November 4, 2024, 10:50am UTC](https://swi-prolog.discourse.group/t/run-tests-forall-output/8570/6 "2024-11-04T10:50:03Z")

</div>

@jan Thank you so much for this improvement and @tatut for reporting it !  
This always bothered me but never thought it was a bug…
