Sample test cases

Last updated: May 1, 2025

(If you are a Recruiter using HackerRank for Work and looking for information about Test Cases, refer to the Defining test cases for coding Questions topic. )

In your HackerRank Coding questions, test cases help your test setter validate your coding logic to address all the different scenarios in a problem and verify your output against the expected output. Test cases can be categorized as Sample and Hidden test cases.

Sample Test Cases

Sample test cases are those which are executed first when you run your code. Their purpose is to carry out an initial validation of your coding logic over simple use cases and verify your output against the exact expected output. 

Your test setter may include one or more sample test cases in your coding question to help you gain a better understanding of the problem and the type of input and output expected from your coding logic. Only the Sample test cases display the execution result and the particular input values, the output from your code, and the expected output.

Example

For a coding logic to return the sum of two integers, the following is the Sample test case execution status in a HackerRank coding Test.

Sample_Test_Cases.jpg
Sample test case execution status with input and output values presented

Tip: You can also download the sample input and output values for a coding Question from the output area in your Tests, as shown in the illustration below. The input and output values will be available in separate files. 

Download_Sample_Inout_and_Output.jpg
Downloading sample input and output values

The Sample test cases may or may not involve a score for successful execution. In many cases, these are included to better understand the problem and initial validation of your coding logic.