0
0
Testing Fundamentalstesting~10 mins

Risk analysis for testing in Testing Fundamentals - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test simulates a risk analysis process for a software feature. It verifies that high-risk areas are identified and prioritized for testing to reduce potential failures.

Test Code - PyTest
Testing Fundamentals
def risk_analysis(features):
    # Assign risk scores based on impact and likelihood
    risk_scores = {}
    for feature, data in features.items():
        impact = data.get('impact', 0)
        likelihood = data.get('likelihood', 0)
        risk_scores[feature] = impact * likelihood
    # Sort features by risk descending
    prioritized = sorted(risk_scores.items(), key=lambda x: x[1], reverse=True)
    return prioritized


def test_risk_analysis():
    features = {
        'login': {'impact': 9, 'likelihood': 8},
        'search': {'impact': 6, 'likelihood': 5},
        'profile_update': {'impact': 7, 'likelihood': 3},
        'notifications': {'impact': 4, 'likelihood': 2}
    }
    result = risk_analysis(features)
    expected_first = ('login', 72)  # 9*8
    assert result[0] == expected_first, f"Expected highest risk feature to be {expected_first}, got {result[0]}"
    assert result[-1][0] == 'notifications', "Expected lowest risk feature to be 'notifications'"
Execution Trace - 7 Steps
StepActionSystem StateAssertionResult
1Test startsTest environment ready, risk_analysis function and test_risk_analysis defined-PASS
2test_risk_analysis() is calledFeatures dictionary with impact and likelihood values passed to risk_analysis-PASS
3risk_analysis calculates risk scores for each featureRisk scores computed: login=72, search=30, profile_update=21, notifications=8-PASS
4risk_analysis sorts features by risk descendingSorted list: [('login', 72), ('search', 30), ('profile_update', 21), ('notifications', 8)]-PASS
5test_risk_analysis asserts highest risk feature is 'login' with score 72First item in result is ('login', 72)assert result[0] == ('login', 72)PASS
6test_risk_analysis asserts lowest risk feature is 'notifications'Last item in result is ('notifications', 8)assert result[-1][0] == 'notifications'PASS
7Test ends successfullyAll assertions passed, risk analysis prioritization verified-PASS
Failure Scenario
Failing Condition: If risk scores are calculated incorrectly or sorting fails
Execution Trace Quiz - 3 Questions
Test your understanding
What does the test verify about the 'login' feature?
AIt has the lowest risk score
BIt is not included in the risk analysis
CIt has the highest risk score
DIt has the same risk score as 'search'
Key Result
Performing risk analysis helps testers focus on the most critical features first, improving test efficiency and reducing chances of major failures.