<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>Looks close enough to what I tend to do. It could be worth firing off something like the following to double-check that your knowledge base and working memory are as expected prior to each test.</div><div><br></div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp;&nbsp;<span style="color: #4f76cb">/**</span></div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(79, 118, 203);">&nbsp;&nbsp; &nbsp; * Iterates through the facts currently in working memory, and logs their details.</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(79, 118, 203);">&nbsp;&nbsp; &nbsp; *&nbsp;</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(79, 118, 203);">&nbsp;&nbsp; &nbsp; * <span style="color: #91afcb">@param</span> session The session to search for facts.</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(79, 118, 203);">&nbsp;&nbsp; &nbsp; */</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; <span style="color: #931a68">public</span> <span style="color: #931a68">static</span> <span style="color: #931a68">void</span> printFacts(KieSession session) {</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; &nbsp; &nbsp; StringBuilder sb = <span style="color: #931a68">new</span> StringBuilder();</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(57, 51, 255);"><span style="color: #000000">&nbsp; &nbsp; &nbsp; &nbsp; sb.append(</span>"\n************************************************************"<span style="color: #000000">);</span></div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(57, 51, 255);"><span style="color: #000000">&nbsp; &nbsp; &nbsp; &nbsp; sb.append(</span>"\nThe following facts are currently in the system..."<span style="color: #000000">);</span></div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #931a68">for</span> (Object fact : session.getObjects()) {</div><div style="margin: 0px;"><font face="Monaco"><span style="font-size: 11px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.append(</span></font><span style="font-family: Monaco; font-size: 11px; color: rgb(57, 51, 255);">"\n\nFact:&nbsp;</span><font color="#3933ff" face="Monaco"><span style="font-size: 11px;">“</span></font><font face="Monaco"><span style="font-size: 11px;">&nbsp;+ fact.toString());</span></font></div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(57, 51, 255);"><span style="color: #000000">&nbsp; &nbsp; &nbsp; &nbsp; sb.append(</span>"\n************************************************************\n"<span style="color: #000000">);</span></div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0326cc">log</span>.info(sb.toString());</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; }</div><p style="margin: 0px; font-size: 11px; font-family: Monaco; min-height: 15px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; <span style="color: #4f76cb">/**</span></div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(79, 118, 203);">&nbsp;&nbsp; &nbsp; *&nbsp;</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(79, 118, 203);">&nbsp;&nbsp; &nbsp; * <span style="color: #91afcb">@return</span> A String detailing the packages and rules in this knowledge base.</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(79, 118, 203);">&nbsp;&nbsp; &nbsp; */</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; <span style="color: #931a68">public</span> <span style="color: #931a68">static</span> String kbaseDetails(KieBase kbase) {</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; &nbsp; &nbsp; StringBuilder sb = <span style="color: #931a68">new</span> StringBuilder();</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #931a68">for</span> (KiePackage p : kbase.getKiePackages()) {</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.append(<span style="color: #3933ff">"\n&nbsp; Package : "</span> + p.getName());</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #931a68">for</span> (Rule r : p.getRules()) {</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.append(<span style="color: #3933ff">"\n&nbsp; &nbsp; Rule: "</span> + r.getName());</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(57, 51, 255);"><span style="color: #000000">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #931a68">return</span><span style="color: #000000"> </span>"Knowledge base built with packages: "<span style="color: #000000"> + sb.toString();</span></div><div style="margin: 0px; font-size: 11px; font-family: Monaco;">&nbsp; &nbsp; }</div></div><div><br></div><div><br></div><br><div><div>On 29 Apr 2014, at 09:47, richardhands &lt;<a href="mailto:richard.hands@uk.sopragroup.com">richard.hands@uk.sopragroup.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">I've written a base class to do the heavy lifting of creating all the Kie<br>resources etc and to give me a stateless session back that my unit tests can<br>all use. &nbsp;Each test calls the method in this base class to set up stuff, and<br>then adds facts and globals and does a fireall.<br><br>however, i get random unit test failures. &nbsp;sometimes the suite will work<br>perfectly, sometimes rule x will fail, sometimes rule f will fail etc. &nbsp;I'm<br>convinced it's got to be something to do with the way i'm setting up the<br>initial resources, and maybe they're getting re-used incorrectly from one<br>test to another (i expect a brand new clean statelesssession on each test)<br>but i can't see what i'm doing wrong. &nbsp;The documentation around the new Kie<br>stuff is still being built around how i'm trying to do stuff, so i'm a bit<br>lost. &nbsp;Each unit test class is designed to test all the rules in on .drl<br>file, but there can be many .drl files in one package so i don't want to use<br>the api's for loading a package, i am having to create a filesystem and load<br>the drl file into it. &nbsp;can anyone see anything obviously wrong in my base<br>class that might cause this intermittent failure?<br><br>thanks<br><br><br><br><br><br><br>--<br>View this message in context: <a href="http://drools.46999.n3.nabble.com/Drools-6-Junit-Random-Failures-tp4029379.html">http://drools.46999.n3.nabble.com/Drools-6-Junit-Random-Failures-tp4029379.html</a><br>Sent from the Drools: User forum mailing list archive at <a href="http://Nabble.com">Nabble.com</a>.<br>_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>https://lists.jboss.org/mailman/listinfo/rules-users<br></blockquote></div><br></body></html>