I am using the library lift json in scala to deserialize some json configurations to my Config
Case class. For deserializing I have a class called Parser
. It has a get method which tries to deserialize the config and if successful then returns scala.util.Success(Config)
otherwise scala.util.Failure
. My question is what is the correct way to write unit test for Parser class ?
- Should I just keep various valid and invalid configuration jsons in test data and just assert
isFailure
andisSuccess
from the result of the get method ? - Or for each test json configuration I have, I create an exact Config class by hand, and then assert
isFailure
,isSuccess
and ifisSuccess
also assert that deserialized config and the one I created by hand are the same ?