-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 
Author Message
 Post subject: Can i generate code and test Simultaneously?
PostPosted: Thu Jan 28, 2010 5:43 am 
Beginner
Beginner

Joined: Tue Jan 19, 2010 7:11 am
Posts: 23
Location: Spain
Hello

I would like generate code and generate tests for this code simultaneously.

I am use hibernate tool from ant task with jdbcconfiguration, i only generate entities (<hbm2java...>), and i would like generate test for this entities...

My questions are, is posible?? and how to do this??

Thanks!!!!!


Top
 Profile  
 
 Post subject: Re: Can i generate code and test Simultaneously?
PostPosted: Thu Jan 28, 2010 8:47 am 
Senior
Senior

Joined: Tue Aug 04, 2009 7:45 am
Posts: 124
Probably you eant to generate some class for each entity, then custom template could help you.
Go into hibernate-tools.jar and find existing templates (.ftl files) which are used when you run your reverseengeneering. Use them as a start point for creation your custom templates.
How to attach them see here: http://docs.jboss.org/tools/3.0.0.GA/en ... l/ant.html.


Top
 Profile  
 
 Post subject: Re: Can i generate code and test Simultaneously?
PostPosted: Thu Jan 28, 2010 11:17 am 
Beginner
Beginner

Joined: Tue Jan 19, 2010 7:11 am
Posts: 23
Location: Spain
Thank you Dmitry and vyemialyanchyk but my intention was generate code with hibernate.reveng.xml, MyStrategy.java and templates, but the less change the templates better, i would like change the configuration files. If in the future, hibernate change pojo/pojo.ftl.... it's a problem for me.

Thanks!!!!


Top
 Profile  
 
 Post subject: Re: Can i generate code and test Simultaneously?
PostPosted: Fri Jan 29, 2010 3:18 am 
Senior
Senior

Joined: Tue Aug 04, 2009 7:45 am
Posts: 124
If you are worring about such future just copy the templates from hibernate-tools.jar and use them as custom.


Top
 Profile  
 
 Post subject: Re: Can i generate code and test Simultaneously?
PostPosted: Fri Jan 29, 2010 3:38 am 
Beginner
Beginner

Joined: Tue Jan 19, 2010 7:11 am
Posts: 23
Location: Spain
Thanks Dmitry.

I know how to do it, but the developers don't know how... They are going to have to configure two files for their developments, if besides this they have to configure the templates.... is hard for them.

Thanks again!!!


Top
 Profile  
 
 Post subject: Re: Can i generate code and test Simultaneously?
PostPosted: Sun Jan 31, 2010 5:32 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
What tests is it exactly you think that can be generated without customization ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: Can i generate code and test Simultaneously?
PostPosted: Mon Feb 01, 2010 6:07 am 
Beginner
Beginner

Joined: Tue Jan 19, 2010 7:11 am
Posts: 23
Location: Spain
Hi Max, sorry for i don't response yesterday...

I want generate unit test for my generated entities (entity per table).

Especially I would like to check that all fields of an entity remain in the database.

Thanks!!!!


Top
 Profile  
 
 Post subject: Re: Can i generate code and test Simultaneously?
PostPosted: Mon Feb 01, 2010 6:16 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
alvarorodriguezmoroy wrote:
I want generate unit test for my generated entities (entity per table).

Especially I would like to check that all fields of an entity remain in the database.


Ok, and I don't see how tests that is generated at the same time as you reverse engineer would
test anything related to that since the code is generated based on the columns being there.

If you want to test that the mapping has all fields, then using something like schemavalidator (built-in to hibernate) would be an better option.

btw. if we wanted to generate test code for the entities to persist them through hibernate then we
would need to know what kind of data goes into them and generate a sane object model - to do that requires
some (heavy duty) magic.

In case your object model is super trivial (i.e. no relationships) some of this is trivial to generate but then
again what is the value of those beyond what schemavalidator can do ? If you do find value for that then
you can simply create some custom templates to use with your metamodel to generate the testing you think
make sense.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: Can i generate code and test Simultaneously?
PostPosted: Tue Feb 02, 2010 7:49 am 
Beginner
Beginner

Joined: Tue Jan 19, 2010 7:11 am
Posts: 23
Location: Spain
Thanks Max.

I didn't response you before because my level of english is very bad (i think that is obvious for the way of writing ), and i didn't understand you.

Only say you that the objetive was generate code and test and throw the tests every days and check that the data base had not changed, but i will have to do the tests to hand.

Thanks!!!


Top
 Profile  
 
 Post subject: Re: Can i generate code and test Simultaneously?
PostPosted: Thu Feb 18, 2010 2:01 am 
Newbie

Joined: Thu Feb 18, 2010 1:57 am
Posts: 2
thanks mate for sharing this...Its should be very helpful to me...

_________________
COSHH risk assessment | CDM coordinator


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.