Test case runner

Difficulty: MEDIUMCategory: LLDFrequency: 1Asked On 2025-04-17

Problem Statement

We have N test cases that need to be scheduled for execution. These test cases may have dependencies — for example, test case T1 might need to run before T2 and T3. However, we don’t need to manually manage these dependencies, as we’re already provided with a method:

1List<Task> getNextTasks(List<Task> executedTasks)

This method takes a list of executed tasks and returns the list of tasks that are ready to be scheduled next (i.e., their dependencies are satisfied).

Our goal is to execute all tasks in parallel, respecting their dependencies.

Error Handling

If any test case fails during execution, the entire pipeline should be aborted immediately. That is, a failure in any child thread should signal the parent thread to stop further execution.

Follow-up Questions

•How would child threads terminate?
•If a failure occurs in any child thread, it should notify the parent and all running threads should be gracefully terminated
•How would exceptions from child threads be logged?


You don't have to use executor pool etc. use plain locks, signals, and wait/await

Solution

Comments