Adding Test Cases

A test case is an input and output for a programming question, which allows you to validate the candidate's code.

Let’s say that we want the candidate to write a function/method that adds two numbers. In this case, the test cases could be something like this.

Test case 1

Input: 10, 20

Expected output: 30

Test case 2

Input: 30, -5

Expected output: 25

Test case 3

Input: -30, -40

Expected output: -70

Test case 4

Input: 35, abcd

Expected output: Input value is not a number

Creating a New Test Case

  1. While creating a new question, or while editing an existing one, click on the “Add test case” button on the Test Cases step.

    Screenshot 2023-12-12 at 2.37.29 PM.png
    Add Testcase

  2. In the Add Test Case pop-up, define the test case's name, score, input, and expected output.

    Screenshot 2023-12-12 at 2.39.50 PM.png


  3. Click on the Save changes button to add the Test case.

Objects as test case input

NeetoRunner allows users to add objects as test case inputs. This may not be obvious from the add test case panel. The object that you pass as input must be of the following format.

{ "key1": "value1", "key2": "value2" }

Here's a video on how to handle this.

Handling expected outputs for objects can also be tricky. Please take a look at this video to handle this consistently.

Avoid multiple input/outputs in the same test case

Users often tend to add multiple input outputs in the same test case, e.g.

Screenshot 2023-12-12 at 2.42.01 PM.png

This means that the test case would have two inputs and the candidates would have to print 2 outputs related to those inputs.

The better way of doing this would be to split the inputs into two separate test cases.

Can't find what you're looking for?