Search code examples
testingintegration-testingsystem-testing

In testing an application, can I assume a previous test will pass in other tests?


I am testing the functionality of an application. One of the tests is to verify that the application can connect to an external source. The rest of the tests require that the application is connected. Is it all right to write a test to test for the application's ability to connect and then the other tests to assume the application can connect and have one of the test steps as "Connect to External source"?

Thanks.


Solution

  • This should be considered on test by test basis. You can skip that assertion unless it's going to complicate interpreting the results of the tests a lot.

    There is an even better way - you can implement a /health endpoint in the application itself. It could invoke all its dependencies and return 200 OK if everything is okay and 500 if not. Your deployment scripts could hit that endpoint. Therefore this becomes a post-deployment check instead of a functional test. So you won't even start running your tests if one of the dependencies is down.