génération de jeux de test pour les programmes de règles 1 er juillet 2009 ilog chair of software...
TRANSCRIPT
![Page 1: Génération de jeux de test pour les programmes de règles 1 er juillet 2009 ILOG Chair of Software Engineering Freiburg Universität Bruno Berstel berstel@informatik.uni-freiburg.de](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518c5c9550346991f8b57be/html5/thumbnails/1.jpg)
Génération de jeux de testpour les programmes de règles
1er juillet 2009
ILOG Chair of Software EngineeringFreiburg Universität
Bruno [email protected]
Michel [email protected]
![Page 2: Génération de jeux de test pour les programmes de règles 1 er juillet 2009 ILOG Chair of Software Engineering Freiburg Universität Bruno Berstel berstel@informatik.uni-freiburg.de](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518c5c9550346991f8b57be/html5/thumbnails/2.jpg)
2 / 13
What does The User want?
• As a user:– I have a program made of a collection of rules– I usually have no specification of this program – I have to write a test suite that covers well the
program
• I want you to:– At least generate the input data for these tests
• with a “good coverage”
– If possible, also generate the expected results
![Page 3: Génération de jeux de test pour les programmes de règles 1 er juillet 2009 ILOG Chair of Software Engineering Freiburg Universität Bruno Berstel berstel@informatik.uni-freiburg.de](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518c5c9550346991f8b57be/html5/thumbnails/3.jpg)
3 / 13
The rules we talk about
• Condition-Action rules– If the value of the shopping cart is greater than 100, then give a gift to the customer.
– If the subject of the mail contains “enlarge your Rolex”, then mark the mail as junk.
• Made of– A condition (or guard): a formula with variables on an
object model– An action part: assignments, calls to methods of the
object model– Object model = graph of objects with attributes
• Not a tree: beware of aliasing
![Page 4: Génération de jeux de test pour les programmes de règles 1 er juillet 2009 ILOG Chair of Software Engineering Freiburg Universität Bruno Berstel berstel@informatik.uni-freiburg.de](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518c5c9550346991f8b57be/html5/thumbnails/4.jpg)
4 / 13
What does it mean totest a rule?
And furthermore togenerate tests for a rule?
![Page 5: Génération de jeux de test pour les programmes de règles 1 er juillet 2009 ILOG Chair of Software Engineering Freiburg Universität Bruno Berstel berstel@informatik.uni-freiburg.de](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518c5c9550346991f8b57be/html5/thumbnails/5.jpg)
5 / 13
A test for one rule
• A rule is a relation– between input states and output states– partial, as the rule may not be executable in some
states
• A test case for a rule is– an initial state (input data)– whether the rule is expected to be executable– if so, the expected resulting state (output data)
![Page 6: Génération de jeux de test pour les programmes de règles 1 er juillet 2009 ILOG Chair of Software Engineering Freiburg Universität Bruno Berstel berstel@informatik.uni-freiburg.de](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518c5c9550346991f8b57be/html5/thumbnails/6.jpg)
6 / 13
Generating tests for one rule
• To find an initial state where the rule is executable:– Build a logical formula from the rule guard
– Solve the satisfiability of this formula• We use a constraint solver• Plus preferences to choose among multiple solutions
• Are we interested in states where the rule is not executable?– If so, solve the satisfiability of the negation of the guard
• Probably interested in exploring all disjuncts
– To be addressed with respect to the other rules.
![Page 7: Génération de jeux de test pour les programmes de règles 1 er juillet 2009 ILOG Chair of Software Engineering Freiburg Universität Bruno Berstel berstel@informatik.uni-freiburg.de](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518c5c9550346991f8b57be/html5/thumbnails/7.jpg)
7 / 13
What does it mean totest a rule program?
And furthermore togenerate tests for a rule program?
![Page 8: Génération de jeux de test pour les programmes de règles 1 er juillet 2009 ILOG Chair of Software Engineering Freiburg Universität Bruno Berstel berstel@informatik.uni-freiburg.de](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518c5c9550346991f8b57be/html5/thumbnails/8.jpg)
8 / 13
What’s the difference?
Gold35 y.o.
Gold65 y.o.
Silver65 y.o.
if the customer category is Gold, then…
if the customer age is greater than 60, then…
r1
r2
r1
r2
![Page 9: Génération de jeux de test pour les programmes de règles 1 er juillet 2009 ILOG Chair of Software Engineering Freiburg Universität Bruno Berstel berstel@informatik.uni-freiburg.de](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518c5c9550346991f8b57be/html5/thumbnails/9.jpg)
9 / 13
A test suite that “covers well”…
• In absence of overlapping rules– generate one test case for each rule– optionally
• several cases for each rule if it reassures the user• a test for the case where no rule is applicable
• A simple approach to overlaps– disambiguate overlaps– generate one test for each case
![Page 10: Génération de jeux de test pour les programmes de règles 1 er juillet 2009 ILOG Chair of Software Engineering Freiburg Universität Bruno Berstel berstel@informatik.uni-freiburg.de](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518c5c9550346991f8b57be/html5/thumbnails/10.jpg)
10 / 13
It’s not enough
Gold35 y.o.
Gold65 y.o.
Silver65 y.o.
if the customer category is Gold, then…
if the customer age is greater than 60, then…
r1
r1r2
r2
r1
r2
?s1
s2
s3
![Page 11: Génération de jeux de test pour les programmes de règles 1 er juillet 2009 ILOG Chair of Software Engineering Freiburg Universität Bruno Berstel berstel@informatik.uni-freiburg.de](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518c5c9550346991f8b57be/html5/thumbnails/11.jpg)
11 / 13
General approach
• Consider the rule combinations and their maximal executions– either as transitions– or as executions– or as execution histories
• These combinations do not overlap (when confluent)– generate one test case for each
![Page 12: Génération de jeux de test pour les programmes de règles 1 er juillet 2009 ILOG Chair of Software Engineering Freiburg Universität Bruno Berstel berstel@informatik.uni-freiburg.de](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518c5c9550346991f8b57be/html5/thumbnails/12.jpg)
12 / 13
Conclusion
![Page 13: Génération de jeux de test pour les programmes de règles 1 er juillet 2009 ILOG Chair of Software Engineering Freiburg Universität Bruno Berstel berstel@informatik.uni-freiburg.de](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518c5c9550346991f8b57be/html5/thumbnails/13.jpg)
13 / 13
Conclusion
• Generating one test case for one rule is “easy”.
• Generating a test suite for a rule program involves computing its executions.– Cf. bounded model checking?
• The concept of “coverage” raises the issues of overlapping and confluence.– An overlapping analysis could be helpful to start with– So could a confluence analysis
![Page 14: Génération de jeux de test pour les programmes de règles 1 er juillet 2009 ILOG Chair of Software Engineering Freiburg Universität Bruno Berstel berstel@informatik.uni-freiburg.de](https://reader035.vdocuments.site/reader035/viewer/2022070306/5518c5c9550346991f8b57be/html5/thumbnails/14.jpg)
14 / 13
Merci