I hope this helps you to define your best way to implement the mocks.
The project explains the general idea, there are semantics and translation problems with the readme.md
, i'll working on that soon please be patient. Please forget my English/misspelling let me known of any correction
I was working on this Demo project of how to implement Protractor + CucumberJS + sugar-step . Right now it contains a very very simple Angular APP and 3 E2E Test.
The demo is working, but is unfinished yet, still need some features which i think are useful for E2E Testing.
- The first test check a service against a default service (Dev
environment mock)
- The Second test check that the service request returns an error
with status code 404
- The Third test check that the service request returns an error with status code 500
How can i set different Mock responses for each Scenario?
- Using Cucumber's Around Feature, which can be used to inject a
angular.module('mock-Service-response-x',fn...)
before any feature or scenario, and remove it after the feature or scenario runs
What can be tested this way?
- Any kind of scenarios, responses with extreme delays, response any Status Code, response special data for test very particular scenarios which otherwise will be impossible/hard to obtain from a normal back-end service, like data inconsistency on the back-end
Why implement your UI-Mocks in AngularJS and not with a proxy?
UI Control, (of course depending of your particular needs) using Angular you can do things like: disable ngAnimations
or jQuery
animations entirely, Mock your local browser Date
, to emulate behaviors which depends on date in a automatically.
Cost, (depending of your project) the cost of implement a local proxy for all the web services on every dev environment can be expensive (in hardware or effort or hours of implementation).
Dependency, if your dev teams are working in parallel, it's more likely to be depending from each-other, if the UI team is working in a feature that depends on a X Web Service, knowing the implementation specs the UI team can create simple mocks to continue with his work making more probable the deliver on time of the hole project
All those arguments depends of which project are you working on, and doesn't mean at all that this is the best solution, but i'm more in favor of keep the project layers independent from each other, and be able to release a new feature in one layer no matter if other layer is delayed in his own new features.
To anyone who reads this, any comment, correction or suggestion will be more than welcome