I am writing an application which has a LAMP backend, which provides a RESTful API. This API is consumed by an AngularJS front-end.
I have unit and integration tests for the API / GUI in isolation. Now I am expanding my test horizon to encompass a full front-to-back test suite.
I've been playing around with Protractor, which has been extremely useful for the browser-based inputs for my front-to-back tests. However, I'm strugging to see how I can integrate this with the orchestration of the PHP backend.
Within the PHP integration tests, I have a set of utility classes that populate the system (i.e. database) with a pre-determined universe. For example; there is a pre-created user called "Bob", and an administrator called "Alice".
Between each integration test case, the entire universe is re-set to this base state, so that any interactions with Bob & Alice in the test are re-set.
This is one example of the orchestration I would like to manage from Protractor. However, I cannot see an easy pattern to integrate with the PHP code which constructs the test universe.
After the initial population of the world, there are other orchestration tasks I would like to be able to execute to get the system into the desired target state; e.g. locking Bob's user account.
Without wanting to access the MySQL DB directly from the protractor code, how can I re-use my PHP logic and invoke the business logic from Protractor?
I could offer RESTful orchestration URLs. But this seems dangerous, as it would pose a serious risk if ever released to production.
There are a number of suggestions on other StackOverflow questions (e.g. this one) which suggest using Mocks. These seem to completely miss the mark; given protractor is designed for front-to-back tests.
Aucun commentaire:
Enregistrer un commentaire