[rules-users] How to determine which rules fired under what conditions, for testing

tari-manga matteo.mortari at gmail.com
Tue Mar 26 16:44:49 EDT 2013


Ciao, as you mentioned in your original post you're starting with Drools, I
want to share with you I find particularly useful to have a
KnowledgeRuntimeLogger [1] during my JUnit tests.

It basically produce an audit xml file which you can later open with the
Drools tools in the Eclipse IDE with the Drools Audit view [2] and very
precious when I'm starting to write new project and its first tests.

While I'm here I want to mention at the same time, in the early JUnit test I
write, I do normally get a great help by the JUnit test tag timeout element
[3]. It helps me prevent infinite rule firing loop by forcing the test
method termination after a while if not completed; normally I'm bad at this
and when I'm starting a brand new project I tend to bump into this kind of
problems.

There are other helpful stuff, but these are the ones I would start from.

Hope this will help you,
Ciao
Matteo
[1]
http://docs.jboss.org/drools/release/5.5.0.Final/drools-expert-docs/html_single/index.html#d0e3370
[2]
http://docs.jboss.org/drools/release/5.5.0.Final/drools-expert-docs/html_single/index.html#d0e8537
[3] http://junit.sourceforge.net/javadoc/org/junit/Test.html#timeout%28%29


jmagnare wrote
> Just to clarify, for anyone else who might offer advice, my original
> desire was to have some kind of information about what rule fired, and
> what object it fired for.
> 
> 
> -- James
> 
> 
> 
> 
> 
> 
> On 3/26/13 1:15 PM, "Grant Rettke" <

> grettke@

> > wrote:
> 
>>You might think differently about unit testing, set up your tests so
>>you *know* the data is there, and add or retract facts, and verify
>>their presence as a matter of success of failure.
>>
>>There are also more advanced approaches that others will surely share
>>soon.
>>
>>On Tue, Mar 26, 2013 at 3:11 PM, Magnarelli, James
>><

> James_Magnarelli@

> > wrote:
>>> Though all of those are worthy pursuits, I want to do it in the sense of
>>> unit testing to make sure that I have defined the rule correctly.
>>>
>>> Thanks for your rapid response, by the way. I really appreciate it.
>>>
>>> -- James
>>>
>>>
>>>
>>>
>>>
>>>
>>> On 3/26/13 1:08 PM, "Grant Rettke" <

> grettke@

> > wrote:
>>>
>>>>Do you want to do that in the sense of unit testing to make sure you
>>>>have defined the rule correctly?
>>>>
>>>>Or, do you want to understand more about the dynamic behavior as your
>>>>system executes for profiling? Or learning more about your model?
>>>>
>>>>On Tue, Mar 26, 2013 at 3:05 PM, jmagnare <

> james_magnarelli@

> >
>>>>wrote:
>>>>> I'm fairly new to Drools, but a fair amount of digging and searching
>>>>>hasn't
>>>>> brought me closer to an answer on this:
>>>>>
>>>>> Is there a way for me to determine, at runtime, which rules were fired
>>>>>and
>>>>> with what inputs?
>>>>>
>>>>> I am looking to use this my JUnit tests, to make sure that the rules I
>>>>>want
>>>>> to be fired are firing when I expect them to.
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>>http://drools.46999.n3.nabble.com/How-to-determine-which-rules-fired-un
>>>>>de
>>>>>r-what-conditions-for-testing-tp4023063.html
>>>>> Sent from the Drools: User forum mailing list archive at Nabble.com.
>>>>> _______________________________________________
>>>>> rules-users mailing list
>>>>> 

> rules-users at .jboss

>>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>
>>>>
>>>>
>>>>--
>>>>Grant Rettke | ACM, AMA, COG, IEEE
>>>>

> grettke@

>  | http://www.wisdomandwonder.com/
>>>>Wisdom begins in wonder.
>>>>((λ (x) (x x)) (λ (x) (x x)))
>>>>
>>>>_______________________________________________
>>>>rules-users mailing list
>>>>

> rules-users at .jboss

>>>>https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>>
>>> _______________________________________________
>>> rules-users mailing list
>>> 

> rules-users at .jboss

>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>>
>>-- 
>>Grant Rettke | ACM, AMA, COG, IEEE
>>

> grettke@

>  | http://www.wisdomandwonder.com/
>>Wisdom begins in wonder.
>>((λ (x) (x x)) (λ (x) (x x)))
>>
>>_______________________________________________
>>rules-users mailing list
>>

> rules-users at .jboss

>>https://lists.jboss.org/mailman/listinfo/rules-users
> 
> 
> _______________________________________________
> rules-users mailing list

> rules-users at .jboss

> https://lists.jboss.org/mailman/listinfo/rules-users





--
View this message in context: http://drools.46999.n3.nabble.com/How-to-determine-which-rules-fired-under-what-conditions-for-testing-tp4023063p4023069.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list