combining scalaxb with scalacheck -


i wonder how make use of scalacheck on types generated scalaxb stemming complex xsds one:

http://wiki.xmldation.com/@api/deki/files/379/=pain.001.001.03.xsd

the actual documents resemble payments , want restrict test-data in 1 or other way (account owners/numbers, amounts, countries).

the actual components test are: xml-parsers checking syntax , producing error-messages, xml-parsers parsing documents record-like data-structure, xml-printers writing such documents.

would feasible ?

one of ways can check validity of scalaxb-generated case classes , typeclass instances roundtrip. it's not perfect, should test consistency of classes.

for example, start xml document, parse case class, , turn xml document again. you'd need define generator covering various scenarios.

or, go other way, start arbitrary case classes, convert them xml documents, , parse case classes. think more straightforward define case class generators the arbitrary generator examples:

implicit lazy val arbbool: arbitrary[boolean] = arbitrary(oneof(true, false)) 

for example, arbitrary instance following addresstype2code can defined in same way.

<xs:simpletype name="addresstype2code">   <xs:restriction base="xs:string">     <xs:enumeration value="addr"/>     <xs:enumeration value="pbox"/>     <xs:enumeration value="home"/>     <xs:enumeration value="bizz"/>     <xs:enumeration value="mlto"/>     <xs:enumeration value="dlvy"/>   </xs:restriction> </xs:simpletype> 

using these building blocks, arbitrary instance complex type can constructed implicit def arbtree[t].

the benefit of having arbitrary instances around, can proceed test business logic code it, pretending xml document exists.


Comments