+ Start a Discussion
punnoosepunnoose 

json paser unit testing

How do i unit test a Json Parser.We have a lot of json parser installed in out appliaction.Please do suggest some ways to install unit testing for  json parser

Regards

Punnoose

varsha_30varsha_30

Hi

I think JSON class is already having a testmethod. If you run that class you will find the code coverage.

Thanks

punnoosepunnoose

CAn you please elaborate

Punnoose

varsha_30varsha_30

Hi Punnoose

 

Please explain your issue. What I get is that, you are having a class named "JsonParser" and now you want to write a testmethod for it. If this this is the issue then, you can check there might already a testmethod written in the class. If you will run JsonParser class, it will give you the code coverage. Hope it helps or may be I am not getting you issue clearly. If not, please clarify.

 

Thanks

tomcollinstomcollins

Can you use the built-in JSON parser instead of your own?  If so, you won't need to unit test it, and it's probably more reliable than the one you're using.

 

If you need to test a JSON parser, then you'll have to create pieces of JSON (both properly formatted and JSON with errors in it) and pass that into your parser.  Check the output of the parser to ensure that it's processing the JSON correctly.

 

If you're saying that you need to test code that uses the JSON parser, you're going to have to pass various bits of JSON code into it, such that all execution paths are covered.