-->
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.  [ 4 posts ] 
Author Message
 Post subject: Techniques for unit-testing *.hbm.xml files
PostPosted: Wed Feb 25, 2004 4:13 pm 
Newbie

Joined: Wed Feb 25, 2004 4:06 pm
Posts: 2
I'm trying to figure out the best way to unit-test my *.hbm.xml files. Do not misunderstand...I'm not trying to unit-test Hibernate itself, nor am I trying to unit test anything that uses Hibernate. What I want my tests to tell me is if my understanding of how my *.hbm.xml files is correct.

To that end, I've started down the road of using SchemaExport to generate a schema from my *.hbm.xml files, import that into Hypersonic (in-memory for speed), and then perform some basic tests to ensure that the results are as I expect.

Has anyone else done this and have some tips/examples or can anyone offer any better ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 25, 2004 6:31 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
What exactly do you want to test? You could probably use something like http://xmlunit.sourceforge.net/, or probably let schemaExport generate to a text file and run the tests on it, don't know, you are the first one I heard of trying something like that.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 25, 2004 6:53 pm 
Newbie

Joined: Wed Feb 25, 2004 4:06 pm
Posts: 2
gloeglm wrote:
What exactly do you want to test?


I don't want to test that the XML file looks correct. If that's all I wanted, I could XmlUnit or some such mechanism.

No, I'm more interested in whether or not the *.hbm.xml files do what I think that they do. Specifically with regard to relationships, I'm wanting to test that I setup the mapping files correctly, defining the relationships to behave as my application will expect them to behave.

Such a test would create the schema fresh (using SchemaExport), plug in some initial test data (perhaps using DbUnit), then be a client to Hibernate, ensuring that Hibernate (using my mapping files) retrieves and persists everything as expected.

I'm a bit surprised if nobody else is testing this way. The mapping files are a piece of code that makes up my system, so why wouldn't I want to test them? They're also something that I'm likely to screw up if I start tweaking with them, so I'd like a suite of test cases to tell me if I break something.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 26, 2004 12:12 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Yes, the hibernate unit test package does exactly what ou mention (although it does not "pre-load any data into the test db).

Quote:
I'm a bit surprised if nobody else is testing this way. The mapping files are a piece of code that makes up my system, so why wouldn't I want to test them? They're also something that I'm likely to screw up if I start tweaking with them, so I'd like a suite of test cases to tell me if I break something.

Because your not really testing your mapping files. You are really testing use cases of your system and how the semantics of those use cases jive with how you have the entities mapped.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.