Open yuenmh opened 1 year ago
Thanks for the suggestion. This idea is good for a testing infrastructure, but probably not for scoring infrastructure. The local tests are like a testing infrastructure, where it's all or nothing. But the private tests use a scoring infrastructure, which rely on a non-pytest style, so we can give feedback, partial credit, and more control. We can refer to HO0, which gives a little peek at how the infrastructure is implemented.
However, please feel free to implement the pytest style testing on your own local end.
Thanks again, we encourage feature requests, so let us know if there are more!
Yes testing on the student's side is what I'm thinking of here. Writing tests quickly is probably more important for students when working through the problems than it is for the course staff writing cases for the autograder. ~I'll see what I can do, and link it here before making a PR because it will probably take a few iterations.~ Sorry it was late and I misread your message about implementing it.
Summary
Testing system similar to
pytest
.Motivation
I find that writing new tests in the
grade_local.py
file can be, to be frank, a little cumbersome, because of all the boilerplate code in the file deriving the base question class. I propose a system which uses the existing infrastructure to provide a more streamlined experience when writing tests, which would look something like thepytest
API.Details
The new addition is just a subclass of
cse40.question.Question
that loads all the functions in a file that are marked by a decorator. This can be added to the local grading script like this (taken from the HO3 one):The tests file would look something like this:
The first argument to a test function is the submission, and all following args are filled with the corresponding values from
additional_data
. As you can see, the resulting API is actually not much different from the current one, it just lacks most of the visual noise, and also would use python asserts, which I feel are a bit more natural than testing with if statements.My contribution
If the course staff/maintainers of this repo find this interesting, I would like to work on implementing it. Additionally if you would like to see a more concrete proposal I will be willing to clarify or code up a working example.