How to run custom unit tests?

How to run custom unit tests?

AutoGradr supports a wide variety of ways to grade your students' assignments. You can use out-of-the-box solution for IO comparison with helpful diffs, you can run JUnit tests for Java projects, or you can run your own custom tests!

You can run custom tests in any language of your choosing. Here are the steps:

Custom Tests

  1. Start by creating an entrypoint file for your language (Main.java for Java, main.cpp for C++, main.c for C, main.py for Python etc.). More Info
  2. In this file, define the appropriate main function and call your student's code. You can run any custom logic to make sure that the student should pass the test case.
  3. The goal for this file is to write a file to the relative path: './../custom_report.json'
  4. The report contains the test case results as defined by your code. This is read by AutoGradr and the feedback is provided to students. The format for the JSON file is as follows:
[
  {
    "order": 1,
    "label": "Unit test #1",
    "didPass": true
  },
  {
    "order": 2,
    "label": "Unit test #2",
    "didPass": false
  }
]

You can even group your tests by following this format:

[
  {
    "order": 1,
    "label": "Unit test #1",
    "tests": [
      {
        "order": 1,
        "label": "Sub Unit test #1",
        "didPass": false
      },
      {
        "order": 2,
        "label": "Sub Unit test #2",
        "didPass": false
      }
    ]
  },
  {
    "order": 2,
    "label": "Unit test #2",
    "didPass": false
  }
]

Setting up the Project on AutoGradr

Once your entrypoint file is ready, setup the Project on AutoGradr:

  1. Create a new Project
  2. Select 'Unit Tests' as the Test Case Type
  3. For test case files, upload your entrypoint file

Putting it all together

When a student submits their code, AutoGradr will run your file along with the student's code. Everything will be compiled together. Finally, as your program outputs the custom report, AutoGradr will read it and give students instant feedback.

results for ""

    No results matching ""