At Stripe, a simple test automation script receives a list of test result strings and must produce a compact summary. Write a function that parses the results, counts each status, and returns the names of failed tests in the order they first appear.
Implement a function summarize_test_results(results) where results is a list of strings. Each string has the format "<test_name>:<status>", where <status> is one of PASS, FAIL, or SKIP. Return a dictionary with four keys:
passed: number of tests with status PASSfailed: number of tests with status FAILskipped: number of tests with status SKIPfailed_tests: list of unique failed test names in first-seen orderIf a test name appears multiple times with status FAIL, include it only once in failed_tests, but count every failed entry in failed.
Example 1
results = ["login:PASS", "checkout:FAIL", "search:SKIP", "checkout:FAIL"]{"passed": 1, "failed": 2, "skipped": 1, "failed_tests": ["checkout"]}checkout appears once in the failed test list.Example 2
results = ["api:PASS", "ui:PASS"]{"passed": 2, "failed": 0, "skipped": 0, "failed_tests": []}0 <= len(results) <= 10^4: separatorPASS, FAIL, or SKIPresults = ["login:PASS", "checkout:FAIL", "search:SKIP", "checkout:FAIL"]Output{"passed": 1, "failed": 2, "skipped": 1, "failed_tests": ["checkout"]}WhyThere is one pass, two fail entries, and one skip. `checkout` is listed once because failed test names must be unique.results = ["api:PASS", "ui:PASS"]Output{"passed": 2, "failed": 0, "skipped": 0, "failed_tests": []}WhyBoth tests passed, so only the pass counter increases.results = ["a:FAIL", "b:FAIL", "a:FAIL", "c:SKIP"]Output{"passed": 0, "failed": 3, "skipped": 1, "failed_tests": ["a", "b"]}WhyThe failed count includes all three failed entries, but the failed test list keeps only the first occurrence of each failed test name.0 <= len(results) <= 10^4Each result string contains exactly one `:` separatorTest names are non-empty stringsStatus is always one of `PASS`, `FAIL`, or `SKIP`def summarize_test_results(results):