We have some unit tests for testing mappings that appear to pass, because they are not actually building a session factory - like, a referenced class is not mapped (ExplicitColumnNameIsAlwaysMapped) -, so we must take care with that.
RP On Sunday, September 7, 2014 3:28:26 PM UTC+1, Oskar Berggren wrote: > > I guess I mostly rely on integration tests to fail if the mapping have > somehow become mismatched - i.e. collection elements not being saved > despite the application itself expecting they will be without an explicit > call and stuff like that. > > I also have a test that generate the SQL schema based on mappings, and > compare it to an Expected sql script. This was I can ensure that if/when > the mapping is changed there needs to be a corresponding change in the > expected SQL., which means a developer will actually look at it and also > create the actual db migration script with similar changes. > > /Oskar > > > > 2014-09-05 8:21 GMT+02:00 David Perfors <[email protected] <javascript:>>: > >> Hi All, I like to have your opinion about something. >> In a project I am working on a lot of mistakes were made when creating >> the NHibernate mappings. Most of those mistakes were made around >> collections and cascading. When we found out, I started to write unittests >> for those collections to prove that the problems were in the mappings and >> not in NHibernate. So for each mapped entity I am writing tests to prove >> that I can do simple crud actions, entities in the collections are deleted >> or just dereferenced when the entity gets deleted. That kind of stuff... On >> one side this is to make sure the mappings are correct (which helps a lot >> with the mappings for the collections), on the other side it is to make >> sure we don't change the mapping without making sure we need to. >> >> But now I am at the point where I think "How far should I go", which is >> of course a question you could not answer, but I can be more specific. >> Should I try to tests things like nullability, when our database creation >> scripts are also specifying it? Should I try to test that a many-to-one >> mapping is not lazyloaded, or it's cascading is set to None? >> >> So are you guys testing your mappings? And how far do you go? >> >> Greetings, >> David >> >> -- >> You received this message because you are subscribed to the Google Groups >> "nhusers" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> Visit this group at http://groups.google.com/group/nhusers. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/nhusers. For more options, visit https://groups.google.com/d/optout.
