0
0
Testing Fundamentalstesting~10 mins

Performance test reporting in Testing Fundamentals - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test simulates running a performance test on a web application and verifies that the performance report is generated correctly with key metrics like response time and throughput.

Test Code - unittest
Testing Fundamentals
import unittest

class PerformanceReportTest(unittest.TestCase):
    def test_performance_report_generation(self):
        # Simulate performance test results
        performance_data = {
            'average_response_time_ms': 120,
            'max_response_time_ms': 300,
            'throughput_rps': 50,
            'error_rate_percent': 0.5
        }

        # Generate report string
        report = (f"Average Response Time: {performance_data['average_response_time_ms']} ms\n"
                  f"Max Response Time: {performance_data['max_response_time_ms']} ms\n"
                  f"Throughput: {performance_data['throughput_rps']} requests/sec\n"
                  f"Error Rate: {performance_data['error_rate_percent']}%")

        # Verify report contains all key metrics
        self.assertIn('Average Response Time', report)
        self.assertIn('Max Response Time', report)
        self.assertIn('Throughput', report)
        self.assertIn('Error Rate', report)

        # Verify values are correct
        self.assertIn('120 ms', report)
        self.assertIn('300 ms', report)
        self.assertIn('50 requests/sec', report)
        self.assertIn('0.5%', report)

if __name__ == '__main__':
    unittest.main()
Execution Trace - 12 Steps
StepActionSystem StateAssertionResult
1Test startsTest framework initializes the test case-PASS
2Simulate performance test results with average response time 120 ms, max 300 ms, throughput 50 rps, error rate 0.5%Performance data dictionary created in memory-PASS
3Generate performance report string with all metricsReport string contains all performance metrics formatted-PASS
4Check report contains 'Average Response Time'Report string is availableassertIn('Average Response Time', report)PASS
5Check report contains 'Max Response Time'Report string is availableassertIn('Max Response Time', report)PASS
6Check report contains 'Throughput'Report string is availableassertIn('Throughput', report)PASS
7Check report contains 'Error Rate'Report string is availableassertIn('Error Rate', report)PASS
8Verify '120 ms' value is in reportReport string is availableassertIn('120 ms', report)PASS
9Verify '300 ms' value is in reportReport string is availableassertIn('300 ms', report)PASS
10Verify '50 requests/sec' value is in reportReport string is availableassertIn('50 requests/sec', report)PASS
11Verify '0.5%' value is in reportReport string is availableassertIn('0.5%', report)PASS
12Test ends successfullyAll assertions passed, test completes-PASS
Failure Scenario
Failing Condition: Performance report string is missing one or more key metrics or values
Execution Trace Quiz - 3 Questions
Test your understanding
What does the test verify about the performance report?
AIt measures the actual response time of the application
BIt checks the UI layout of the report page
CIt contains all key performance metrics with correct values
DIt verifies database connection speed
Key Result
Always verify that performance test reports include all important metrics with correct values to ensure accurate and useful results.