Link Search Menu Expand Document

Test Cases

With our take-home pads and challenges, you have the ability to run test cases. Test cases allows you to test a candidates code against certain outputs. A test case allows the candidate to test their code against a test cases you provide. You will also be able to view the test-cases once the candidate has finished their take-home challenge.

Here is an example. Let’s say I want the candidate to write a function that reverses a string. I can have a test case that would have an input of “hello world”. The output of the the candidates function must return “dlrow olleh”.

Note: Challenges are an entirely different library from the questions used for live pads. (Those can still be found under “Questions” in the left navigation.)

To get started, follow these instructions:

  • From the CoderPad dashboard click on Challenges in the side navigation.
  • This will bring you to the Challenges page. Once on the page, click on the “Create New Challenge with Test Cases”
  • On the first half of the Challenge creation page, enter your challenge information. This challenge title, starting language, candidate instructions and an internal description for your team.
  • The second half is where you will enter your test cases. Start by adding a function signature. The function signature is the parameter(s) that will be used in the function. E.g. if you wanted the candidate to reverse a string, the function signature would have data type as string, and the parameter name as phrase for example.
  • You will then need to specify a return value data type. Again, referring back to our example of reverse string, we want the candidate to return a string
  • Now you can add your actual test cases. This should showcase the return values of what the candidates code should actually return.
  • Example: argument = “hello world”, return value: “dlrow olleh”.
  • You also have the option of making the test cases visible or not visible to a candidate. Make sure you have the correct test cases that you would like the candidate to see.