Introduction to the Coding Hire Automated Challenge
This challenge is designed to test your ability to read code, find bugs in that code, create test cases exposing those bugs, and then fix them. The code in most of the questions is very simple and makes use of basic data structures (arrays, hashtables) and basic control structures (if statements, while loops, for loops).
When you begin, you will be given the following:
- A problem statement, describing what the function is supposed to do
- An area for unit tests
1. Read the Code, Find the Bug
The first thing you should do is find the bug in the code. You'll want to review the problem statement and carefully read through the code until you've spotted it.
2. Add a Failing Test
Once you've located the bug, you need to add a failing test case. There will be a place for you to enter the input and the expected output. It will be checked to make sure it is valid.
Test case inputs will be JSON data types (number, string, boolean, array, associative array and null). If a function takes multiple parameters, the input should be a comma separated list.
Each question will have at least one sample test case so you can see the format. The sample case will be passing (because it doesn't hit the code path containing the bug).
3. Fix the Code
Once you've added a failing test case, you will be asked to fix the code so that it fully meets the requirements (and your test case passes). The modifications required are usually minor.
Once you've solved the first question, you will be given another. You will have 20 minutes to get through as many questions as possible.
Once you've completed the challenge your results will be scored and compared to other candidates. Your score is primarily based on how many questions you complete within the time limit.
Your initial tendancy may be to start trying a bunch of random test cases until you find one that works. However, you will have much better luck if you slow down and read the code first. Once you spot the bug in the code, creating a failing test case will be easy.