Pregunta

As far as I know, end to end tests are black box tests, so I should not know anything about the application, just use its interface and check the result... But how should I check a read-only api, if I cannot touch the database to set the data I intend to read with it?

Is it really crucial to write the fixtures with an e2e approach? In my current case, I have a www and a members subdomain. The content of the www subdomain is managed from the member's subdomain with proper authorization. I want to develop with tdd beginning with the e2e tests ending with the unit tests... If I want to develop the www subdomain first, I cannot make an e2e fixture, because the data writing is not implemented yet. Should I first implement the member's subdomain if I want to develop this way? I intend to use event sourcing, so it would be very easy to make a DB fixture, just inserting some domain events, that would be all...

I don't understand the logic of this kind of testing, if I cannot insert anything to the database, it will be empty at the beginning. But then I won't have a user with proper authorization, so I cannot write into the database, and so I cannot test anything. So this is a catch-22... At least I have to have a test user with the proper authorization, but making a test user requires writing to the database... I think my brain burned out :D

¿Fue útil?

Solución

All tests need data to test against, even black box testing. Typically you will have a setup function that populates your database with data before the test runs. You will likely have a teardown step as well, which might restore the database to a pre-test state. This in no way violates any rules of testing.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top