Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have developed two web services. The main service is a RESTful service (using

ID: 652352 • Letter: I

Question

I have developed two web services. The main service is a RESTful service (using DB), and another UI service that uses the RESTful service.

Say I want to test the UI for now (integration tests), every test will makes changes in the prod DB. More then that, if in the RESTful service, there are one-way functions for security reasons. I mean that functions that can not be revert (Say if mark item as 'done', I can't edit or delete it anymore)?

This things are very logical, the most websites I know have the same situation. All these websites are not testable?

Explanation / Answer

First of all, you shouldn't be testing against your production database. If you ever need to rerun your tests after the application has gone live (and you will need to do that), you run a serious risk of losing or corrupting data that is vital to the business.

So, instead of testing against the production database, you test against a test database (which should structurally be a copy of the production one). Then you can also add facilities to your test harness to reset that test database to a known state just before or after running a particular test.
This way, you can test the correct (inter-)operation of the two web services.

If the correct operation of the RESTful service can be presumed, you can also opt for a fake/mock of the RESTful service, which gives all the expected responses for the particular test, but doesn't actually persist anything.