c# - Best practice for Unit test data generation -
i have unit test contains huge data needs compared actual custom object. have create expected custom object , populate huge data, rightnow hard coding expected custom object in code. there scenario have test differenct set of data input method testing. depanding on set of data have relative output actual respons (huge data). there best practice above scenario other hard coding expected values in code? (some thing xml or csv).
you can create code serialize object using xmlserializer.
you need call code when application running , have correct object in memory.
save xml file , construct object in test xml.
you may have several xml files can cover different scenarios.
in application had code imports data external webservice. generated few xmls service response objects (they huge) , use them test parsing logic.
update: trick works entities objects. cannot serialize/deserialize class works files or database.
here can find sample code. http://www.jonasjohn.de/snippets/csharp/xmlserializer-example.htm
Comments
Post a Comment