When working through a CodeSignal evaluation, you may want to create custom test cases to help debug code and investigate any issues you’re facing.
You can create custom test cases when working through the General Coding Framework, Industry Coding Framework, or any other single function questions (including progressive single-function).
Please note that creating custom test cases does not impact your score. Scores are calculated using either visible or hidden test cases defined by the question.
To create custom test cases:
Click the “Custom Tests” tab in the lower part of your screen
Click + Add Custom Test. Here, you will be able to create a custom test from scratch.
A window will pop up that allows you to define your test case. This window is non-modal, which means you can continue to work within the IDE editor and test cases, and the content of the pop-up won’t be impacted. You can also resize or move the pop-up window to optimize your experience.
Please note that any other modals (such as View Diff or navigation tabs on the left) will not be available while the “create test” pop-up is open. Any unavailable modals will shake when clicked to indicate that they cannot be used.
Specify your inputs and expected outputs. Both inputs and outputs are required fields. The question will define the type of inputs and outputs that you can work with, as noted beneath the input and expected output headlines. Depending on the question, you may be working with integers, strings, arrays, true/false, or others)
Click Done to create the test case. Clicking the X in the top right or hitting cancel will not create the custom test.
Follow this same process to add additional test cases, starting with + Add test case, or duplicate it via the branching icon to the right side of the custom test.
Working with your test cases:
To run your tests, you can click the blue run custom test button and all of your tests will be run simultaneously.
Additionally, there are a few tools you can leverage to work with your test cases:
- Karat icons- Can be used to reorder your test cases
- Pencil icon- Can be used to edit your test case
- Branching icon- Can be used to duplicate your custom test case, which allows you to create a new test case that builds on what you’ve already written without starting over. The new custom test will be placed underneath the one you’ve already created, and can be moved up or down using the karat icons mentioned above. Note that you cannot duplicate the standard test cases that come with the question; you can only duplicate your custom test cases.
- Trash icon- Can be used to delete your test case. When the pop up appears, click confirm to delete the test case. Clicking “cancel” or closing out of the window via the X in the upper right corner will not delete your test case.
- Play button- allows you to run custom tests individually
Green check marks indicate that your test case passed. A red triangle appears when the test case did not pass.
Notes:
Each time you run test cases, the existing verdicts will be erased (in both the Test and Custom Test tabs), but not the points or score. Run or Submit as many times as you’d like, it won’t impact your score!
For progressive questions, you cannot pass a level with custom test cases, you can only use custom test cases to debug your code. Your ability to move to the next level will be determined by the standard test cases that are prescribed in the question.
Interviewers won’t be able to see you working in the modal (defining inputs/outputs), but they will be able to see the end result of the test case that was created.