I have been thinking about alternate uses of OPath I created for EVars plug-in. And it occurred to me that I can very well use it for my unit testing (which involves pretty complex insurance object model) and for things like JSPs where I really hate to write ten lines of Java code just to display some value.
So I wrote a port of OPath for Java object model (less than 200 lines of real code). Following example should explain how it can add some value to your development efforts:
Consider an example of code for simple Accessible Swing Table :
If you are writing a UI test to see specific table's column heading, you just write following
Collection<Object> findAll = OPathReflectiveInterpreter.findAll(frame, "//dataModel//@val\\$column.*");
assertEquals("First Name",((Object[])findAll.toArray()[0])[0]);
This is very trivial test, of course. But it is sufficient to express the power of OPath micro-scripting.
If you like to try it out for unit-testing or templating check-out the download here (You will also need opath.jar).
Disclaimer: This is experimental work at best, it might be slow and it might have bugs at this time.
0 comments:
Post a Comment