In testing, a similar principle is involved where a certain result is expected, or a set of results to be returned for the actions applied.
If these results don't appear then the test in question is deemed to have failed. Each of these test components is known as a test case. In the above examples, the test cases would have been 'Test whether the key opens the door'
It must be known what result needs to be expected if the test is run as it should be.
So for example if a car is being tested to see whether it is stable enough if an elk ran in front of it, when evasive action was taken by violently turning the steering wheel.
The expected result would be that the car remained upright and did not rollover. However when actually running the test, if the car rolled over then it would be deemed as failing the test. It would be pointless having a test where the outcome expected was to see if the car rolled over.
As it would serve no purpose to the car manufacturer. Who doesn't want their car to rollover and then have to compensate in millions, to any injured parties as a result of their vehicle rolling over.
Instead they will definitely make several test cases where they test that their vehicle is stable.
Designing a product or service to fail to deliver what is expected of it, isn't what any organisation will invest their money in.