0
0
Testing Fundamentalstesting~15 mins

Test estimation techniques in Testing Fundamentals - Build an Automation Script

Choose your learning style9 modes available
Estimate test effort using three-point estimation
Preconditions (2)
Step 1: Review the test case to understand the scope
Step 2: Provide optimistic time estimate (O) in hours
Step 3: Provide pessimistic time estimate (P) in hours
Step 4: Provide most likely time estimate (M) in hours
Step 5: Calculate the estimated time using formula: (O + 4*M + P) / 6
Step 6: Record the calculated estimate
✅ Expected Result: The calculated estimated time matches the formula result and is recorded correctly
Automation Requirements - Python unittest
Assertions Needed:
Verify the calculation formula is applied correctly
Verify the output estimate is a float and within expected range
Best Practices:
Use clear function names
Use parameterized tests for different inputs
Include assertion messages for clarity
Automated Solution
Testing Fundamentals
import unittest

class TestEstimationTechniques(unittest.TestCase):
    def three_point_estimate(self, optimistic, most_likely, pessimistic):
        return (optimistic + 4 * most_likely + pessimistic) / 6

    def test_three_point_estimate(self):
        # Example inputs
        optimistic = 2.0
        most_likely = 4.0
        pessimistic = 8.0

        estimated_time = self.three_point_estimate(optimistic, most_likely, pessimistic)

        expected = (2.0 + 4 * 4.0 + 8.0) / 6

        self.assertIsInstance(estimated_time, float, "Estimated time should be a float")
        self.assertAlmostEqual(estimated_time, expected, places=5, msg="Estimate calculation is incorrect")

if __name__ == '__main__':
    unittest.main()

This test defines a function three_point_estimate that applies the formula (O + 4*M + P) / 6.

The test test_three_point_estimate uses example values for optimistic, most likely, and pessimistic times.

It calculates the estimate and asserts two things: the result is a float, and the value matches the expected calculation.

This ensures the estimation logic is correct and the output type is valid.

Common Mistakes - 3 Pitfalls
Using integer division instead of float division
Not validating input types before calculation
Hardcoding expected values without formula
Bonus Challenge

Now add data-driven testing with 3 different sets of optimistic, most likely, and pessimistic inputs

Show Hint