0
0
Testing Fundamentalstesting~20 mins

Test prioritization in Testing Fundamentals - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Test Prioritization Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why prioritize tests in a large project?

Imagine you have a big software project with thousands of tests but limited time to run them all before a release. Why is test prioritization important in this situation?

ATo run tests that take the longest time first to finish testing faster.
BTo run tests randomly so every test has an equal chance to run.
CTo run only the oldest tests because they are more reliable.
DTo run the tests that are most likely to find bugs first, saving time and improving quality.
Attempts:
2 left
💡 Hint

Think about which tests give the best value early.

Predict Output
intermediate
2:00remaining
Output of prioritized test execution order

Given the following test cases with priorities, what is the order of test execution?

Testing Fundamentals
tests = [
  {'name': 'LoginTest', 'priority': 2},
  {'name': 'PaymentTest', 'priority': 1},
  {'name': 'SignupTest', 'priority': 3},
  {'name': 'ProfileTest', 'priority': 2}
]

# Tests run in ascending order of priority (1 is highest)
execution_order = [test['name'] for test in sorted(tests, key=lambda x: x['priority'])]
print(execution_order)
A['SignupTest', 'LoginTest', 'ProfileTest', 'PaymentTest']
B['LoginTest', 'ProfileTest', 'PaymentTest', 'SignupTest']
C['PaymentTest', 'LoginTest', 'ProfileTest', 'SignupTest']
D['ProfileTest', 'LoginTest', 'SignupTest', 'PaymentTest']
Attempts:
2 left
💡 Hint

Lower priority number means higher priority.

assertion
advanced
2:00remaining
Correct assertion for test priority filtering

You want to write an assertion to check that only tests with priority 1 or 2 are selected for execution. Which assertion is correct?

Testing Fundamentals
selected_tests = [
  {'name': 'LoginTest', 'priority': 2},
  {'name': 'PaymentTest', 'priority': 1},
  {'name': 'SignupTest', 'priority': 3}
]

# Which assertion below correctly verifies all selected tests have priority 1 or 2?
Aassert all(test['priority'] in [1, 2] for test in selected_tests)
Bassert all(test['priority'] == 1 or 2 for test in selected_tests)
Cassert any(test['priority'] == 1 or 2 for test in selected_tests)
Dassert all(test['priority'] == 1 and test['priority'] == 2 for test in selected_tests)
Attempts:
2 left
💡 Hint

Use all() and check membership with in.

🔧 Debug
advanced
2:00remaining
Identify the bug in test prioritization code

What is the bug in this Python code that tries to prioritize tests by priority but fails?

Testing Fundamentals
tests = [
  {'name': 'TestA', 'priority': 3},
  {'name': 'TestB', 'priority': 1},
  {'name': 'TestC', 'priority': 2}
]

# Attempt to sort tests by priority
sorted_tests = sorted(tests, key=lambda test: test.priority)
print([t['name'] for t in sorted_tests])
AThe sorted function is missing the reverse=True parameter to sort descending.
BThe code uses test.priority instead of test['priority'], causing an AttributeError.
CThe lambda function should return test['name'] instead of test.priority.
DThe print statement should use sorted_tests.name instead of list comprehension.
Attempts:
2 left
💡 Hint

Check how dictionary keys are accessed in Python.

framework
expert
3:00remaining
Best practice for integrating test prioritization in CI pipeline

You want to integrate test prioritization in your Continuous Integration (CI) pipeline to run critical tests first. Which approach is best?

ATag tests with priority labels and configure the CI to run high-priority tags first, then others later.
BRun all tests in random order every time to avoid bias.
CRun only the oldest tests in the suite to ensure stability.
DRun tests manually outside the CI pipeline to control order.
Attempts:
2 left
💡 Hint

Think about automation and maintainability in CI.