# Test case generation

**URL:** <https://swi-prolog.discourse.group/t/test-case-generation/7053>\
**Category:** General\
**Created:** [December 9, 2023, 11:21pm UTC](https://swi-prolog.discourse.group/t/test-case-generation/7053 "2023-12-09T23:21:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ola](https://avatars.discourse-cdn.com/v4/letter/o/dbc845/32.png) [@ola](https://swi-prolog.discourse.group/u/ola)\
**Post date:** [December 9, 2023, 11:21pm UTC](https://swi-prolog.discourse.group/t/test-case-generation/7053/1 "2023-12-09T23:21:24Z")

</div>

I come here because I have the intuition that constrain logic programming could help to design testcases.  
Right now i am looking at different languages Prolog is one of them.  
And i am curious about all kind resources and directions where to find information or discuss such a topic.

The idea I have is that one could derive from the requirements that describe a software constraints and facts that should be tested.

an example would be  
input is uint8  
output is uint8  
requirements describe how the state should be:  
A: input \<= 50 and output == 1  
B: 100 \< input \<= 200 and output == 2

one could derive from this that

A: input 0…50 and output == 1  
not-A: input 51…255 and output != 1  
B: input 101…200 and output == 2  
not-B: input 0…100, 201…255 and output != 2

It would be interesting to have a program that also identifies that one doesn’t have to test not-A and not-B separately  
like  
not-AB: input 51…100, 201…255 and output != 2 and output != 1

I am wondering what kind of program am i trying to write?  
What are the terms i should search for?

---

<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:** [December 10, 2023, 9:52am UTC](https://swi-prolog.discourse.group/t/test-case-generation/7053/2 "2023-12-10T09:52:45Z")

</div>

I have no direct literature references. Did you try “Prolog software testing” or something similar? Using Prolog for test generation is not uncommon. Its concise description of the expected input-output relation makes it suitable for acting as “wizard” and its non-determinism allows for generating multiple test cases.
