views:

104

answers:

1
+2  Q: 

Unit testing Jade

Hi,

What techniques and design strategies have people used to aid in unit testing Jade applications? In particular, how do people typically go about testing Behaviours - which are tightly coupled to the Agent instance and the Jade environment? I'm aware of the JadeMX project, but this appears to be geared more towards system testing - in particular the message exchange between collaborating agents.

Thanks.

+2  A: 

JADE has a tendency to overuse inheritance, which, as you rightly point out, results (among other things) in highly coupled, difficult-to-test Behaviours.

In work, we wrote an adaptive layer that sits between our Agents/Behaviours and the JADE ones, and allows us to test our behaviours in isolation. We plan to release this as OSS, but there are a few administerial hoops to jump through first.

At home, I've started work on jade-oo, a backwards-compatible refactoring of JADE that uses unit-testable POJOs for Behavioural logic. It's still pretty much in the alpha stage, but so far I've been able to produce Behaviours with much less boilerplate code, and much more testable logic.

Update: I've added examples and documentation to the jade-oo site. Please do take a look and let me know what you think.

dan
Thanks for the reply. The project sounds great, just what's needed. Any chance of a small example of the adaptive layer you mentioned? Thanks.
Strawberry
In a nutshell, we have a set of Agents/Behaviours that inherit from the JADE Agents/Behaviours, one for every JADE type that we use. Each of these has a delegate object, held via an interface, that it passes all of its methods to. These delegate objects can then be unit tested without instantiating any of the JADE base classes. It works, and from the PoV of client code it's pretty clean, but there are a number of issues that can really only be solved by updating the JADE code; hence the fact that I'm working on jade-oo. I'll post examples of how that works on its google code page soon.
dan