lundi 26 janvier 2015

Reset seperate backend service when testing frontend

I have an API project running at localhost:8000 connected to a test database, and I have a front-end angular app running at localhost:9000. How do I reset the database after each front-end test case run? I'm using Protractor for my front-end E2E testing. I do not want to mock or stub the whole backend. Although that will make my test run faster, however, every user interaction will result changes to the server states and followed by several more requests to the same server endpoints, stubbing these endpoints with different returns at different points might be too much code than just talking to a real server. I'd rather reset the database to an initial state or flush all the tables.


One potential way to do it is to write my front-end E2E test suite in my API project. Since now it's ran by the backend test runner, it could easily reset the database before each test case. But I'd rather keep my tests in my front-end project, since my api will also serve other clients, not just the browser client. And since my backend is in php and uses Phpunit for testing, while I'm using Protractor to test my front-end, integrating it into the backend seems to be a bit misplaced.


Have you run into this problem and what's your solution? How do you coordinate the two projects in your E2E (or integration?) test?


Aucun commentaire:

Enregistrer un commentaire