What is expected outcome in software testing?

The expected outcome in software testing is the ideal result that should be achieved once a test case has been executed. Results refer to displayed textual or graphical data, database changes, state changes, links, data transmission, etc.

For every test case, the expected outcome is compared with the actual results, and any mismatch is classified as a defect. The test case, expected outcome, and defect are all documented together.

The diagram below shows how the expected outcome is used during software testing:

Documenting the expected outcome

When including the expected outcome as part of the test documentation, you should ensure that the entry contains sufficient details. A detailed and accurate expected outcome allows testers to adequately address any defects that may arise during the testing process.

To describe the expected outcome, you can refer to 33 sources:

  1. Client specification: the client’s expectations lay the basis for the test’s expected outcome.

  2. Web standards: how widely spread behavior on websites relates to the test case; this allows for parallels to be drawn between the test case and accepted systems.

  3. Self-analysis: the tester’s own expectations for the use case in question.

Suppose that you need to document the expected outcome for a test case that involves playing a video. The examples below show alternative ways of documenting the outcomes.

Poor documentation example:

Test summary: The video is not visible to the user.

Actual outcome: The video failed to play.

Expected outcome: The video should play.

The problem with the above example is that it lacks detail. The tester responsible for addressing the video issue will not be aware of what device the test was conducted on, the network connection strength, etc. Consequently, the fix may fail to address the issue due to the lack of clarity.

Good documentation example

Test summary: The video does not start regardless of network strength.

Actual outcome: Attempts to start the video result in continuous buffering. The test was conducted on a mobile device for a 1010-minute interval with a network speed of 100100 Mpbs.

Expected outcome: The video buffering must not last more than 1010 seconds based on web standards.

In the above example, the tester now has a complete picture of the testing environment and the details regarding the defect.

Code example

Consider a model where you need to store data regarding a person, and the expected outcome of the test case is as follows:

The system should allow the person’s name to be changed without any unexpected behavior.

The code below shows how the expected outcome can be used for a test case:

#include <iostream>
using namespace std;
// Class representing a person
class Person{
public:
// variable to hold the person's name
string name = "default";
// method to change the person's name
void changeName(string a)
{
name = a;
return;
}
// method to check expected outcome
bool checkExpectedOutcome(string a)
{
if(name == a)
{
return true;
}
else
{
return false;
}
}
};
int main() {
// initialize person object
Person newPerson;
// print current name
cout << "The person\'s name is: " << newPerson.name << ".\n";
// update name
newPerson.changeName("Talha");
cout << "The updated name is: " << newPerson.name << ".\n";
// check expected outcome
if(newPerson.checkExpectedOutcome("Talha"))
{
cout << "The test case passed.\n";
}
else
{
cout << "The test case failed.\n";
}
return 0;
}

Explanation

The class Person has two methods:

  1. changeName: updates the person’s name as per the requirements.
  2. checkExpectedOutcome: evaluates if the changeName method worked properly and reports if the expected outcome was met.

First, an object of the Person class, newPerson, is initialized. The changeName method in line 4040 updates the name attribute.

Finally, the expected outcome of the test case is evaluated using the checkExpectedOutcome method in line 4444. Since the name attribute was correctly updated, the checkExpectedOutcome method returns true. As a result, the tester can be sure that the test case has passed, as the actual result matches the expected outcome.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved