0
0
Testing Fundamentalstesting~20 mins

Flaky test management in Testing Fundamentals - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Flaky Test Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Identifying Flaky Tests

Which of the following best describes a flaky test in software testing?

AA test that always fails due to a bug in the code.
BA test that is skipped during test execution.
CA test that runs slowly but always produces the same result.
DA test that sometimes passes and sometimes fails without any code changes.
Attempts:
2 left
💡 Hint

Think about tests that behave unpredictably without changes in the code.

Predict Output
intermediate
2:00remaining
Output of a Flaky Test Simulation

Consider the following Python test simulation code that randomly fails. What is the output after running it once?

Testing Fundamentals
import random

def flaky_test():
    if random.choice([True, False]):
        return 'Test Passed'
    else:
        return 'Test Failed'

result = flaky_test()
print(result)
ANo output
BTest Failed
CSyntaxError
DTest Passed
Attempts:
2 left
💡 Hint

The output depends on random choice; consider one possible output.

assertion
advanced
2:00remaining
Correct Assertion to Detect Flaky Behavior

Which assertion approach best helps detect flaky tests by running the same test multiple times and checking for consistent results?

ARun the test multiple times and assert all results are the same.
BRun the test multiple times and assert at least one pass.
CRun the test once and assert the expected output.
DRun the test multiple times and assert at least one fail.
Attempts:
2 left
💡 Hint

Think about how to confirm a test is stable across runs.

🔧 Debug
advanced
2:00remaining
Debugging a Flaky Test Caused by Timing

Given this test code snippet, which change will most likely fix the flaky behavior caused by timing issues?

def test_load_data():
    data = load_data()
    assert len(data) > 0

# load_data fetches data asynchronously and may not be ready immediately
ARemove the assertion to avoid failures.
BUse a retry loop to check data readiness before asserting.
CRun the test only once to avoid flakiness.
DAdd a fixed sleep delay before asserting the data length.
Attempts:
2 left
💡 Hint

Think about waiting for the data to be ready instead of guessing a fixed delay.

framework
expert
2:00remaining
Best Practice for Managing Flaky Tests in CI Pipelines

In a continuous integration (CI) pipeline, what is the best practice to handle flaky tests to maintain reliable test reports?

AIgnore flaky tests completely to avoid false failures.
BRemove flaky tests from the test suite permanently.
CAutomatically retry flaky tests a fixed number of times before marking as failed.
DRun flaky tests only on developer machines, not in CI.
Attempts:
2 left
💡 Hint

Consider how to balance test reliability and visibility in automated pipelines.