2) appears the best option. Possibly you should create a view or set of views that exercise the services you have created that integrate with the REST backend.
This way you will minimise the cost of maintaining the UI part of the end to end test. If its important to test precisely how the REST calls integrate with your UI, then the cost of using 2) is just what you have to pay. The question also is what are you actually testing. Working that out might answer the question about what testing framework to use. a) If you are concerned about functional correctness of the REST API, you should write unit tests for that. b) If you are concerned about the functional correctness of your Angular code, you should write unit tests for that. c) If you care concerned about the performance/reliability of the REST API, then thats more an end-to-end or performance test . d) If you are concerned about the end-to-end integration of a use cases, then its end-to-end testing. The tools are selected based on your intent and what you need to test, by stating your requirements clearly it should help determine which tool can or must be used. On Tuesday, June 17, 2014 6:03:06 AM UTC+1, Sudheer k.v wrote: > > Hi Paul, Thanks for a quick response. This definitely helps > Yes ideally I am trying to do Integration tests here using real backend. > How should I go about the same ...option I see > 1) Use Karma with httpBackend.Passthrough > 2) Use protractor - this mostly seems to be a UI based automation > framework, which I don't want to take dependency on. UI automation is > mostly flaky and requires more maintenance cost. > 3) Do you have any other Framework in mind that we can use for JS API > based integration testing? Instead of using HTML elements, we want to use > Angular JS APIs directly. > > > Thanks, > Sudheer > > On Monday, 16 June 2014 21:55:34 UTC+5:30, Paul Freeman wrote: >> >> Hi Sudheer >> >> If you were to use the real $http connection you would no longer be doing >> a unit test. >> >> In that case you would be integration testing the app because your result >> would be dependent on the behaviour of the server behind your $http call, >> so for that reason its preferred to use a 100% predictable mock behaviour >> instead of the real connection. >> >> If you are happy that the unit tests are complete for a given component, >> then instead you would create an integration or end-to-end test to confirm >> that the app works with the real back end. >> >> >> On Monday, June 16, 2014 11:45:52 AM UTC+1, Sudheer k.v wrote: >>> >>> i was unable to access rest services using $http while running unit >>> tests with jasmine as test framework and Karma as test runner. >>> >>> -- Instead of using mock services i am trying to call actual services >>> using $http in unit tests. >>> --Is it possible for unit tests to use $http to call actual services >>> instead of mocking the sercvices >>> >>> Thanks in advance!!!!!! >>> >> -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
