{"id":833,"date":"2021-02-24T19:47:55","date_gmt":"2021-02-25T03:47:55","guid":{"rendered":"https:\/\/coderpad.local\/?post_type=doc&#038;p=717"},"modified":"2023-02-02T12:15:07","modified_gmt":"2023-02-02T20:15:07","slug":"test-cases","status":"publish","type":"doc","link":"https:\/\/coderpad.io\/resources\/docs\/interview\/question-bank\/test-cases\/","title":{"rendered":"Test cases"},"content":{"rendered":"\n<p>With take-home projects you have the ability to run test cases. Test cases allow you to test a candidate\u2019s code against certain requirements. You will also be able to view the test cases\u2019 pass\/fail results once the candidate has finished their take-home project.<\/p>\n\n\n\n<p>You set them up during <em>Step 2 &#8211; Add Take-Home Test Cases <\/em>of <a href=\"https:\/\/coderpad.io\/resources\/docs\/interview\/question-bank\/creating-a-question\/\">question creation\/editing<\/a>. <\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><a href=\"https:\/\/d2h1bfu6zrdxog.cloudfront.net\/wp-content\/uploads\/2021\/10\/take-homes.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/coderpad.io\/wp-content\/uploads\/2021\/10\/take-homes-1024x1007.png\" alt=\"The &quot;add take-home test cases&quot; page. Here you have the option of adding input parameters and desired outputs for test cases.\" class=\"wp-image-3219\" width=\"768\" height=\"755\" srcset=\"https:\/\/coderpad.io\/wp-content\/uploads\/2021\/10\/take-homes-1024x1007.png 1024w, https:\/\/coderpad.io\/wp-content\/uploads\/2021\/10\/take-homes-300x295.png 300w, https:\/\/coderpad.io\/wp-content\/uploads\/2021\/10\/take-homes-768x755.png 768w, https:\/\/coderpad.io\/wp-content\/uploads\/2021\/10\/take-homes.png 1194w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\">1. Set up the function signature<\/h2>\n\n\n\n<p>In order to run tests on the solution function, we must know how many parameters are enabled, what types they are, and what the expected return type of the function is.<\/p>\n\n\n\n<p>Parameters should be named and assigned a type using the dropdowns.<\/p>\n\n\n\n<p>You can add multiple parameters to a function by selecting the <strong>Add Parameter<\/strong> button, and repeating the steps to name the parameter and assign the type.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/d2h1bfu6zrdxog.cloudfront.net\/wp-content\/uploads\/2022\/09\/image-64.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"240\" src=\"https:\/\/d2h1bfu6zrdxog.cloudfront.net\/wp-content\/uploads\/2022\/09\/image-64-1024x240.png\" alt=\"The &quot;add take home test cases page&quot; showing the input parameters and an arrow pointing to the &quot;add parameter&quot; button.\" class=\"wp-image-19171\" srcset=\"https:\/\/coderpad.io\/wp-content\/uploads\/2022\/09\/image-64-1024x240.png 1024w, https:\/\/coderpad.io\/wp-content\/uploads\/2022\/09\/image-64-300x70.png 300w, https:\/\/coderpad.io\/wp-content\/uploads\/2022\/09\/image-64-768x180.png 768w, https:\/\/coderpad.io\/wp-content\/uploads\/2022\/09\/image-64.png 1354w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p>If you want to remove a parameter, click the trashcan icon on the left-hand side of the parameter.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><a href=\"https:\/\/d2h1bfu6zrdxog.cloudfront.net\/wp-content\/uploads\/2021\/10\/test_case_item.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/coderpad.io\/wp-content\/uploads\/2021\/10\/test_case_item-1024x497.png\" alt=\"The input parameters section, there are trashcans to the left of each parameter to remove them.\" class=\"wp-image-3220\" width=\"768\" height=\"373\" srcset=\"https:\/\/coderpad.io\/wp-content\/uploads\/2021\/10\/test_case_item-1024x497.png 1024w, https:\/\/coderpad.io\/wp-content\/uploads\/2021\/10\/test_case_item-300x146.png 300w, https:\/\/coderpad.io\/wp-content\/uploads\/2021\/10\/test_case_item-768x373.png 768w, https:\/\/coderpad.io\/wp-content\/uploads\/2021\/10\/test_case_item.png 1245w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p>Finally, you can set the type of the function\u2019s return value<\/p>\n\n\n\n<p>Supported types include:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Integer<\/li>\n\n\n\n<li>String<\/li>\n\n\n\n<li>Integer Array<\/li>\n\n\n\n<li>String Array<\/li>\n<\/ul>\n\n\n\n<p>These types are consistent across all supported take-home project languages. These same types are enabled for both parameter types and return types.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. Add the test case solutions<\/h2>\n\n\n\n<p>Next you&#8217;ll add the inputs and expected outputs you expect to see from a candidate\u2019s solution. <\/p>\n\n\n\n<p>There one test case solution will be automatically added for you to fill out, but you can easily add more by pressing the <strong>Add Test Case<\/strong> button.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/d2h1bfu6zrdxog.cloudfront.net\/wp-content\/uploads\/2022\/09\/image-65.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"488\" src=\"https:\/\/d2h1bfu6zrdxog.cloudfront.net\/wp-content\/uploads\/2022\/09\/image-65-1024x488.png\" alt=\"Test case solutions section with input parameter and required output for that parameter.\" class=\"wp-image-19172\" srcset=\"https:\/\/coderpad.io\/wp-content\/uploads\/2022\/09\/image-65-1024x488.png 1024w, https:\/\/coderpad.io\/wp-content\/uploads\/2022\/09\/image-65-300x143.png 300w, https:\/\/coderpad.io\/wp-content\/uploads\/2022\/09\/image-65-768x366.png 768w, https:\/\/coderpad.io\/wp-content\/uploads\/2022\/09\/image-65.png 1286w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p>You\u2019re able to remove test cases by selecting the trashcan-shaped delete button to the left-hand side of the test case you\u2019d like to remove.<\/p>\n\n\n\n<p>Each test case also includes a toggle of whether to make it visible to the candidate or not. Non-visible test cases are not shown to candidates but are still tested against the candidate code and reported to the interviewer in playback mode.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<p><br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Candidate View<\/h2>\n\n\n\n<p>When a candidate accesses a pad with take-home test cases, they\u2019ll be able to see the visible tests within the<strong> Test Cases<\/strong> tab:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/d2h1bfu6zrdxog.cloudfront.net\/wp-content\/uploads\/2022\/09\/image-61.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"232\" src=\"https:\/\/d2h1bfu6zrdxog.cloudfront.net\/wp-content\/uploads\/2022\/09\/image-61-1024x232.png\" alt=\"A pad with candidate code on the left and the test cases tab open on the right.\" class=\"wp-image-19167\" srcset=\"https:\/\/coderpad.io\/wp-content\/uploads\/2022\/09\/image-61-1024x232.png 1024w, https:\/\/coderpad.io\/wp-content\/uploads\/2022\/09\/image-61-300x68.png 300w, https:\/\/coderpad.io\/wp-content\/uploads\/2022\/09\/image-61-768x174.png 768w, https:\/\/coderpad.io\/wp-content\/uploads\/2022\/09\/image-61-1536x348.png 1536w, https:\/\/coderpad.io\/wp-content\/uploads\/2022\/09\/image-61.png 1599w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p>They can run specific test-cases by checking the desired checkboxes and pressing <strong>Run selected test cases<\/strong>. Once ran, the <em>Pass<\/em> column on the right will update to indicate whether the test was successful or not.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/d2h1bfu6zrdxog.cloudfront.net\/wp-content\/uploads\/2022\/09\/image-62.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"786\" height=\"286\" src=\"https:\/\/d2h1bfu6zrdxog.cloudfront.net\/wp-content\/uploads\/2022\/09\/image-62.png\" alt=\"The results of the test cases. There is an arguments, expected result, and pass column value for each row\/test case.\" class=\"wp-image-19169\" srcset=\"https:\/\/coderpad.io\/wp-content\/uploads\/2022\/09\/image-62.png 786w, https:\/\/coderpad.io\/wp-content\/uploads\/2022\/09\/image-62-300x109.png 300w, https:\/\/coderpad.io\/wp-content\/uploads\/2022\/09\/image-62-768x279.png 768w\" sizes=\"auto, (max-width: 786px) 100vw, 786px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p>You\u2019re also able to see test output from the <strong>Program Output<\/strong> tab, along with the expected and actual results for each failed test.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/d2h1bfu6zrdxog.cloudfront.net\/wp-content\/uploads\/2022\/09\/image-63.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"500\" src=\"https:\/\/d2h1bfu6zrdxog.cloudfront.net\/wp-content\/uploads\/2022\/09\/image-63-1024x500.png\" alt=\"The output window is shown with both the output of the code as well as the results of the test cases.\" class=\"wp-image-19170\" srcset=\"https:\/\/coderpad.io\/wp-content\/uploads\/2022\/09\/image-63-1024x500.png 1024w, https:\/\/coderpad.io\/wp-content\/uploads\/2022\/09\/image-63-300x146.png 300w, https:\/\/coderpad.io\/wp-content\/uploads\/2022\/09\/image-63-768x375.png 768w, https:\/\/coderpad.io\/wp-content\/uploads\/2022\/09\/image-63-1536x750.png 1536w, https:\/\/coderpad.io\/wp-content\/uploads\/2022\/09\/image-63.png 1600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>","protected":false},"parent":1929,"menu_order":2,"template":"","class_list":["post-833","doc","type-doc","status-publish","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/doc\/833","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/doc"}],"about":[{"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/types\/doc"}],"version-history":[{"count":19,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/doc\/833\/revisions"}],"predecessor-version":[{"id":23790,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/doc\/833\/revisions\/23790"}],"up":[{"embeddable":true,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/doc\/1929"}],"wp:attachment":[{"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/media?parent=833"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}