Rack  Unit Grade
1 Rack  Unit Grade
1.1 Installation
1.2 Creating a Grading File
evaluate-exercise
2 Grading Student Files
8.12

RackUnit Grade🔗ℹ

Ismael Figueroa

This manual provides documentation for a simple Racket package for locally grading homework using RackUnit tests and a new raco grade command.

 (require rackunit/grade) package: racket-rackunit-grade

1 RackUnit Grade🔗ℹ

1.1 Installation🔗ℹ

If you have not installed the package yet, run the following command from the command-line:

  raco pkg install rackunit-grade

Note that this package will require Racket v6.0 or newer to install.

Alternatively, you may use the GUI package manager from DrRacket to install the package.

1.2 Creating a Grading File🔗ℹ

To use RackUnit Grade, you first write a grading file, containing all required libraries, and all the tests you want to run. It is recommended to define an individual test-suite for each specific exercise in your homework. For example, let us consider the tests.rkt file, which defines tests for the my-power function:

(require rackunit)
(require rackunit/grade)
 
(define-test-suite tests-my-power
  (check-equal? (my-power 10 2) (expt 10 2))
  (check-equal? (my-power 13 56) (expt 13 56)))
 
(define (my-result-handler results failures numtests suite-name)
  (printf "~a got ~a failures out of ~a tests" suite-name failures numtests))
 
(evaluate-exercise tests-my-power my-result-handler)

In this case, we are evaluating function my-power, by testing it against the reference implementation expt. After defining the tests, we need to call evaluate-exercise.

procedure

(evaluate-exercise exercise-test    
  result-handler)  void
  exercise-test : test-suite?
  result-handler : procedure??
Evaluates the given exercise-test-suite and summarizes the results using result-handler. result-handler takes the following arguments:

2 Grading Student Files🔗ℹ

Now let us consider the homework.rkt file, which contains the solution from a student:

(provide my-power)
(define (my-power base power) 0)

Clearly this definition is wrong. Now, to combine the grading file with the student solution we need to use the new raco command raco grade:

  raco grade homework.rkt tests.rkt

This command will generate a new file grade_homework_tests.rkt in the current directory, which is a simple copy of tests.rkt appended with a (require "homework.rkt") form. Also the new file is run, using dynamic-require. In order for this schema to work, it is required that student files provide all functions that are going to be graded.