Skip to main content

testing databindings and actions

4 replies [Last post]
Joined: 2003-06-10

It seems to me that one of the testing benefits of JDNC is that the UI is separated from the program logic which should lead to easily testable program logic via unit tests.

I haven't dived in here myself yet. Has anyone explored this area? Any suggestions?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2003-07-08

It seems like an obvious idea -- I wonder why I didn't think of it :).

If I understand you correctly you're talking about affixing application level unit testing to the binding framework (or some such endpoint), rather than tests the JDNC team would write, correct?

I'm not sure exactly how the unit tests would be constructed because one piece of code would programatically fire an event (like somebody clicking the "ok" button), and another piece of code would have to check that the proper stuff happened. I'm sure somebody out there has worked on this. I'd hit google if I were you (I seem to remember an article some time ago...perhaps on O'Reilly).


Mark Davidson
Joined: 2006-02-17

There are quite a few unit tests for actions and data. Take a look at following directories or classes:


You can see enough in these packages and classes to get you started.

To run the tests, go to a "make" sub-directory and type:

$ ant test

There are a couple of properties that you can pass into the test target using the "-D" arg.

will run a single JUnit test class


will run all the tests in a package. You must use "/" rather than "." since the package is represented as a sub-directory in the ant property

Good luck and have fun.


Joined: 2003-06-10

Thanks Mark... I should have been more explicit. The actual mechanics of testing I did see in the sources. But I was wondering about how people thought of structuring their code vs with hand code GUIs - wrt testing.

For example, if I use the NetBeans Form builder, I usually end up with the equivalent of my actions, my gui, and my data mixed into one class. Not by design, but by convenience. But with JDNC, the gui is separated out by design. And now I have a choice of separating my actions from my javabeans. On the surface, that seems like a good idea, but if the javabean and the action are tightly related to each other, I have to wonder if they really do belong together (in this case, they'd have high coehsion).

And since I'm no unit testing guru, I'm probably missing a bunch of other issues.

Joined: 2003-06-10

I haven't formulated any opinions yet, but I did find a few articles about this area: