Skip to content

Implement script unit testing

Luc Everse requested to merge metric-type-checking into development


Adds an endpoint where scripts and unit test values can be submitted to to verify that a criteria script is valid. This helps prevent crashing assignments at a very early stage. The values are stored inside the assignment, so later edits that would invalidate these tests can be detected too.

Also links metric instance types to metric names so they can be type-checked and the system can generate suitable template scripts and unit tests for assignments.

Requires UI updates to be functional.

Resolves #100 (closed)


  • Metric names now have an expected (super-)type for instances with that name
  • Creating a new metric type-checks the value, generating a warning (not an error) if there is a mismatch
  • An endpoint where scripts can be tested
  • Testing fixtures to pre-fill tests in the UI with as a quick start and suggestions


  • IntegerMetric and DoubleMetric are subclasses of the new NumberMetric for metric names that do not care about the floatiness of their values
  • Moved metrics endpoints to a separate controller
  • Deprecated metrics.js

Test and Review

To be filled in by the reviewers

  • All of the methods are commented to expectation

  • The methods are tested to satisfaction

  • There are no unnecessary files present in the MR

  • The continuous integration has no problems with the MR

  • The MR is filled in as requested (including labels, milestones, and reviewers)

  • The documentation is up-to-date

  • All nullable parameters are marked as such

Edited by Ewoud Ruighaver

Merge request reports