Test cases are a crucial part of assessing a candidate's code. They consist of specific inputs and expected outputs that verify the code’s correctness and functionality. By covering various scenarios, including edge cases and typical use cases, test cases help ensure that the code behaves as intended.
When a candidate compiles their code, each test case checks the code's execution status and results. The score is based on how many test cases the code passes successfully.
Creating a New Test Case
1. While creating a new coding question or editing an existing one, you will need to follow the steps of creating a new question and eventually come to step 4 which is adding the Testcases.
2. In the Testcases section you can Upload Solution and Add test cases one by one or in bulk via uploading a Zip.
3. While adding a test case enter the mandatory details such as name, difficulty, score, input, output.
4. Select Mark as a sample test case only if you want to identify a test case as a sample type. You can add the required number of sample test cases to a question and choose not to assign scores for them.
5. Similarly, you can add the required number of hidden test cases to the question (uncheck "Mark as a sample test case"). Hidden test cases should contain edge case scenarios to validate the candidates' code solution. When the candidate compiles the code, the hidden test cases will be executed to show the status and help the candidate to know if their code returned the expected results.
5. To avoid EOF issues, we recommend all test cases that require a multi-value input to define the input in the format suggested below:
number of lines (ex. 4) value of line 1 (ex. 100) value of line 2 (ex. 500) value of line 3 (ex. 40) value of line 4 (ex. 200) |
6. Leverage our code stub generator to manage the input parsing for candidates. The test case input format for our code stubs is as below:
5 separate input parameters e.g. foobar(a, b, c, d, e) - separate parameters by newline: 2 3 4 5 6 |
Int / String Array - the size of the array followed by the list of values in the array 3 100 200 300 |
The following image illustrates the candidate's view of the test case execution status for the compiled code in the test. Note that the candidate can only view the input and expected output values for the sample test case. For the hidden test cases, only the test execution results are displayed.
Refer to Key Features of a Detailed Report to know how the test cases show up in a test report.