In your Coding questions, test cases are the different types of inputs to your code to test your defined logic and produce the output. A test case is termed “passed” when the output from your code exactly matches the expected output. Otherwise, the “Wrong Answer” status is indicated against the test case.
Depending on the complexity of your question, the test setter may define one or more test cases to validate your logic. These test cases are automatically executed when you run your code. The results help you understand whether your coding solution can address the edge scenarios in the test cases and generate the expected output.
Following is an illustration of a Coding question in a HackerRank Test. When the code is run, the test cases are executed with the input from the code to display the results and the output.
Typically, the score or grade for a coding problem is calculated and assigned based on the number of test cases that succeed in producing the expected output. Refer to the Evaluation Method of Coding Questions topic for more information.
For Coding questions, your test setter may include the following types of test cases to validate your code against the expected output:
- Sample Test Cases - These are model test cases for initial validation of your logic to help you gain a better understanding of the problem. The sample test cases may or may not include a score for successful execution.
- Hidden Test Cases - These test cases thoroughly validate your logic for various corner cases and involve specific scores for successful execution.