javascalarestakkaspray

how to write test case for rest service in scala akka(spray)


How to mock HttpRespose? I am using scalla, akka with spray for calling rest service which respond with json, I need to write test case for same. suggest me the technology that can be used.


Solution

  • The best option would be to use Spray Test Kit http://spray.io/documentation/1.1.2/spray-testkit/ which comes with predefined methods which allow for some mocking.

    If you need to mock an underlaying library Mockito is a grat choice but there are others like Scalamock you could give a try.

    For JSON checking I had good experience with using spray's json library and checking on the deserialized object.