1

I need to write a unit test which validates the serialization of two attributes of an XML(size ~ 30 KB) file.

What is the best way to provide an input for this test?

Here are the options I have considered:

  1. Add the file to the project and use a file reader
  2. Pass the contents of the XML as a string
  3. Create the XML through a program and pass it

Which is my best option and why? If there is another way which you think is better, I would love to hear it.

asked Nov 12, 2012 at 8:35

1 Answer 1

5

Option 2 is probably awkward since you will have to escape all double quotes " of the XML attributes.

Option 3 just moves the problem to another place.

Go for option 1. With an external XML file, you can use all the advantages of a XML editor to prepare the input.

answered Nov 12, 2012 at 8:37
1
  • 2
    Option 2 is bad because, ignoring all else, you're going to embed a 30KB string in your code. Option 3 doesn't scale for the next time the OP wants to have large XML input. Commented Nov 12, 2012 at 9:23

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.