Skip to main content
What are code stubs? How can I generate them?
Abhishek avatar
Written by Abhishek
Updated over 2 years ago

LEARNING OUTCOME

Hiring Managers will learn about generating and using code stubs in their programming-related questions.

What are code stubs?

Code stub is a piece of code that can be given to the candidates as a Kickstarter in the Test. Code stubs are useful because they save the candidates' time and allows you to test their problem-solving skills better, rather than testing their memory.

To generate code stubs

  1. Login to your WeCP account as a Recruiter or Hiring Manager.

  2. Select the concerned Test from the home page and navigate to the Questions tab at the top.

    Screenshot_2021-08-25_at_12.46.22_PM.png
  3. Click on the down arrow in the Section, to view all the questions of that section, or click on Expand All to view the questions in all the sections.

    Screenshot_2021-08-25_at_2.30.28_PM.png
  4. Choose the question for which you want to generate a code stub and click on the pencil icon corresponding to it.

    Screenshot_2021-08-25_at_11.12.25_PM.png
  5. Further, in the Question Editor, click on the Codestub generator tab and configure the following details:

    1. Function name: Enter the name of the readymade function that you want to provide to the candidate.

    2. Function return type: Enter the return type of the same function.

  6. Further, if you want to add a variable, click on the + New variable button below it.

    For the variable that you want to add, you must specify the following parameters:

    • Type: Enter the data type of the variable.

    • Variable Name: Enter the name of the variable.

    • Size: Specify the size of the variable.

    • Pass to Function: Mark this checkbox if you want to pass the variable to the function.

    • Delete: At some point, if you want to delete that variable, click on the Delete icon corresponding to the variable.

  7. Every time that you want to add a new variable, click on the Add variable button and specify all the required details.

  8. After adding all the variables, click on Generate Code Stub.

    Screenshot_2021-08-25_at_11.42.21_PM.png
    Screenshot_2021-08-25_at_11.48.54_PM.png
  9. Choose the programming language of your choice from the drop-down menu to check the code stub in that language. Following is an example code stub in the Python3 language:

    Screenshot_2021-08-25_at_11.50.40_PM.png
  10. You can also manually make changes to the code stub as per your choice.

  11. Don't forget to click on Save Question to save all the changes.

  12. This code stub will be visible to the candidates in the code editor below the question in the Test environment and act as a Kickstarter for them in the Test.

Did this answer your question?