Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Dali » JPA-Diagram Editor + JUnit4 Test Synch
JPA-Diagram Editor + JUnit4 Test Synch [message #748415] Mon, 24 October 2011 17:28 Go to next message
al  is currently offline al Friend
Messages: 22
Registered: June 2010
Junior Member
Ok, we all must test our code and 100% code coverage is the target.
I like the tool and it keeps the model in synch with the code.

JPA is a standard and true there would be specific things the developer would have to configure (JPA Provider).
Yet, we are generating code with this tool, why not also generate the JUnit4 tests as well...

How hard would it be to add this functionality?
What tool is being used now to generate the JPA code base?
This will save my team loads of time and I would be willing to work on this.
Re: JPA-Diagram Editor + JUnit4 Test Synch [message #749051 is a reply to message #748415] Tue, 25 October 2011 02:30 Go to previous messageGo to next message
al  is currently offline al Friend
Messages: 22
Registered: June 2010
Junior Member
some thing like JUnitdeclet yet using a specific doclet properties file so the one would not have to code the EMF (stub code)...
Setter/Getter methods of properties would test the set/ with transactions, then commit the persist, then open another transaction to obtain the persisted value.

A Pattern of sorts.
Trying to stay away from AOP due to the fact code coverage tools would not be able to report.
Re: JPA-Diagram Editor + JUnit4 Test Synch [message #749820 is a reply to message #748415] Tue, 25 October 2011 13:10 Go to previous messageGo to next message
Stefan Dimov is currently offline Stefan DimovFriend
Messages: 14
Registered: July 2009
Location: Sofia, Bulgaria
Junior Member
It's a good thing to have more code coverage of the JPA Diagram Editor. All the existing JUnit tests for it are implemented manually. We don't use any tool to automatically generate JUnit tests.

I've been working with such tools before and my general impression is that such automatically generated tests are hard to support. It's a pitfall we've been in before. Of course, there are many different frameworks and tools and I'm far from the thought that I know them all. Perhaps there is a tool/framework that could generate easily readable and supportable tests.

In any case I welcome your desire for contribution and I'm open to discuss any particular tool you wish to use to increase the code coverage.
Re: JPA-Diagram Editor + JUnit4 Test Synch [message #749921 is a reply to message #749820] Tue, 25 October 2011 14:16 Go to previous messageGo to next message
al  is currently offline al Friend
Messages: 22
Registered: June 2010
Junior Member
I'm looking at JunitDoclets right now.
It's driven off of Java Doclet to get the method signatures and it will write unit test for accessor methods.
Yet if the method is not an accessor it puts in an empty test.
If we follow stds, it can take a template and generate a super class @BeforeClass or BeforeTest to set things up (As in hsqldb creation and table creation), EMF and stub out the specific items that will have to be changes (Simple properties)
This would give 30-40% unit test generation.

Since Junitdoclet is template based this is more then do able.
I would suggest having the testing be done on a standard.
Unfortunately, JunitDoclet does not look within the method to understand it's structure for alternate course (If, switch, Exceptions)Unit tests.

Second phase:
Taking what is learned from JunitDoclet, create an Eclipse plugin that also uses templates.
The advantage I'm seeing (And I'm just learning) is that with-in Eclipse as a plugin you have more visibility to the source code and "should" be able to look within the method body to add the alternate courses.

So much to consider...

Suggestions, insights?
Re: JPA-Diagram Editor + JUnit4 Test Synch [message #753542 is a reply to message #749921] Thu, 27 October 2011 15:47 Go to previous messageGo to next message
al  is currently offline al Friend
Messages: 22
Registered: June 2010
Junior Member
JunitDoclet can be used for the JP Diagram Editor project itself.
What I'm talking about is having JPA Diagram Editor generate the test as it generates and keeps the java src in sync with the diagram.
Giving more functionality to the tool set.
Re: JPA-Diagram Editor + JUnit4 Test Synch [message #753736 is a reply to message #753542] Fri, 28 October 2011 14:39 Go to previous messageGo to next message
Stefan Dimov is currently offline Stefan DimovFriend
Messages: 14
Registered: July 2009
Location: Sofia, Bulgaria
Junior Member
So, actually you are talking about tests which don't test the editor itself, but they test the model, the enities generated by the JPA developer using Eclipse.

That sounds interesting, but the model is not being generated by the editor only, so if there is such a plugin for generating JUnit tests for the model it shouldn't belong to the JPA Diagram Editor component. It should be placed on a more common level in Dali project or perhaps it should be a separate component.

Of course, it seems reasonable to have integration between such a tool and the editor.

Perhaps we should discuss the whole idea with the Dali project lead - Neil Hauge
Re: JPA-Diagram Editor + JUnit4 Test Synch [message #753755 is a reply to message #753736] Fri, 28 October 2011 15:31 Go to previous messageGo to next message
Neil Hauge is currently offline Neil HaugeFriend
Messages: 470
Registered: July 2009
Senior Member
An interesting idea. This sounds like something that would be a great Eclipse Labs project. You could experiment with different ideas there and perhaps come up with something that would be relevant to more than just Dali. For starters you could work on integrating this with the Dali model in your Lab project.

Let us know if you have questions here on the newsgroup. If this turns into something useable for the Dali project we could look at moving the code base into Dali down the road.

Neil
Re: JPA-Diagram Editor + JUnit4 Test Synch [message #753886 is a reply to message #753755] Sun, 30 October 2011 01:19 Go to previous message
al  is currently offline al Friend
Messages: 22
Registered: June 2010
Junior Member
I've been successful in changing the JUnitDoclet template to generate std junit tests for each accessor method (Java classes generated from JPA Diagram Editor).

So phase one is complete...
Phase two is to duplicate, provide deeper tests .. Via a plugin..
Once completed I will submit.

Previous Topic:Table Generation from Entities with Embeddable Inheritance
Next Topic:Tool to run JPQL queries on the fly
Goto Forum:
  


Current Time: Sat Dec 20 10:39:28 GMT 2014

Powered by FUDForum. Page generated in 0.02439 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software