[Ddtunit-users] Suggestions and ideas to DDTUnit 0.8.5
Brought to you by:
jg_hamburg,
kgellien
|
From: <j.g...@fr...> - 2007-08-12 17:08:38
|
Hi J=FCrgen, thanks for the good feedback. As soon as there is a little more time I will incorporate the fixes =20 to the framework. As for the use of Spring and data driven testing have a look on =20 springunit.sourceforge.net from Ted Velkoff. Based on the experience =20 with DDTUnit he transfered the ideas directly to Spring. Because I am no expert of Spring usage perhaps you are interested to =20 contribute your ideas and implementation to DDTUnit project? - You =20 are welcome to do so! On the jdk issue: would it be helpful to provide a 1.4 compilation of =20= the jar? best regards J=F6rg P.S.: I am experimenting on xml stax support to integrate dbUnit =20 (dbunit.sourceforge.net) support into DDTUnit. Might this be =20 interesting for your work? Am 10.08.2007 um 11:52 schrieb J=FCrgen Su=DFner: > Hi, > > I am using ddtunit to test complex objects in a spring based core =20 > library of a webapplication. During my tests i discovered some =20 > strange behavior in ddtunit. So i modified the sourcecode to fix =20 > this behaviors. With this mail i want to inform you about the =20 > changes i made. Perhaps they will be included in ddtunit. > > -------------------------------------------------------------------- > Content: > > 1. cant use JDK 5 > 2. Nullpointer when creating Collections > 3. class implements list but is no Collection > 4. DDTUnit and Spring > 5. Conclusion > > -------------------------------------------------------------------- > > 1. My Webapplication and therefor its core library must run under =20 > WAS 5.1 therfor i dont have support fo JDK 5. > > The first sollution was to use retroweaver to create 1.4 compatible =20= > classes from the 1.5 binarries. this works fine bur the drawback =20 > ist that i could not wave the sources and i have to user retrowaver =20= > runtime. > > The second idea was to disable all generics and foraech loops to =20 > get a real 1.4 compatible source. > > this works fine for me. So all my modifications i'd like to show =20 > you are based on the 1.4 Source without generics. > > -------------------------------------------------------------------- > > > 2. There is a NullPointer excecption when using a collection within =20= > a collection within a assert tag. > > The following xml fragment shoud demonstrate this > > <test id=3D"2"> > <objs> > <obj id=3D"object1" type=3D"arraylist" = hint=3D"collection"> > <item type=3D"de.dummy.test.Container" = hint=3D"collection"> > <item type=3D"de.dummy.test.Container" = hint=3D"collection"/> > <item type=3D"de.dummy.test.Container" = hint=3D"collection"/> > </item> =09 > </obj> =09 > </objs> =09 > <asserts> > <assert id=3D"result" type=3D"arraylist" = action=3D"isEqual" =20 > hint=3D"collection"> > <item type=3D"de.dummy.test.Container" = hint=3D"collection"> > <item type=3D"de.dummy.test.Container" = hint=3D"collection"/> > <item type=3D"de.dummy.test.Container" = hint=3D"collection"/> > </item> =09 > </assert> > </asserts> > </test> =09 > > used with this UnitTest: > > public void testDoTest() { > > Object container =3D getObject("object1"); > > addObjectToAssert("result", container); > > } > > becaus the assert and the object are equal the test should succeed. =20= > But when using 0.8.5 a NuppPointerException arrouses. > > My Fix to this Problem is: > > CollectionCreatorAction.process contains the following Code > > // do not forget to process the actual root element > if (rootAction.getPrevious() !=3D null) { > rootAction =3D rootAction.process(); > } > > changing to > > // do not forget to process the actual root element > if (rootAction.getPrevious() !=3D null) { > if (!(rootAction.getPrevious() instanceof = CollectionCreatorAction)) { > rootAction =3D rootAction.process(); > } > } > > and the obove Test works... > > I don't know if this is the correct sollution but it works for me. > > -------------------------------------------------------------------- > > 3. CollectionCreaterAction.inject does not recognize classes =20 > implemention only the List interface or the Collection interface > > > This Test will only recognize classes that are subclasses of =20 > AbstractCollection because Collecion is an interface and can never =20 > be a super class. > > if ("java.util.Collection".equals(superclazz.getName()) > || "java.util.AbstractCollection".equals(superclazz > .getName())) { > found =3D true; > } > > in addition to check the superClass relationship you should test =20 > also Class[] superclazz.getInterfaces() and theire superclass =20 > relationships. That will help to accep classes implemention only =20 > the collection interface. Till now i have not implementet this so i =20= > can not provide source code... > > -------------------------------------------------------------------- > > 4. Think about providing a spring connector. > > Becaus i am working with spring i dont want to loose all the power =20 > the AbstractDependencyInjectionSpringContextTest gave me. e.G. =20 > Autowiring or autoTransactionManagement. Maybe it would be an idea =20 > to provie a DDTTestCase that inherits from springs =20 > AbstractDependencyInjectionSpringContextTest or even better another =20= > BaseTestClass than inherrits form springs =20 > AbstractTransactionSpringContextTestCase. So spring users are able =20 > to use DDTUnit in a real comfortable way and combining the power of =20= > DDTUnit with the flexibillity of spring. > > In my case i made a copy of DDTTestCase as DDTSpringTestCase and =20 > combined these classes in a common Interface. Now my =20 > DDTSpringTestCase inherrits from =20 > AbstractTransactionSpringContextTestCase. So i have DDTUnit =20 > Support, autowiring and autoTransactionManagement. > > -------------------------------------------------------------------- > > 5. Ok, thats all for now. > > I think DDTUnit is till now one of the best UnitTestFrameworks. I =20 > hope this ideas might help you to improve DDTUnit quality. If you =20 > have any questions feel free to contact me. > > Regards > Juergen Su=DFner (DDTUnit user) > > > > > > _____________________________________________________________________ > Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! > http://smartsurfer.web.de/?mc=3D100071&distributionid=3D000000000066 > > |