Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Automating Repetitive Test Tasks
00:00
5 left

Automating Repetitive Test Tasks

EasyPython

Problem

As part of QA automation for an Alnylam Amvuttra workflow, a test runner records whether each expected result matches the observed result. Write a function that scans the records and returns the IDs of all failed test cases in their original execution order.

A test case passes when expected equals actual. It fails otherwise.

Formal Specification

Implement collect_failed_tests(results).

  • Input: results, a list of dictionaries. Each dictionary contains three strings: id, expected, and actual.
  • Output: Return a list of test case ID strings whose expected and actual values differ.
  • Do not modify the input list or its dictionaries.

Constraints

  • 0 <= len(results) <= 10^5
  • Every record contains nonempty string values for id, expected, and actual
  • Test case IDs are unique
  • Comparisons are case-sensitive

Function Signature

def collect_failed_tests(results):
Interviewer

Your question is Automating Repetitive Test Tasks. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.