Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stepanzh/scoredtests.jl
Test utilities with scoring.
https://github.com/stepanzh/scoredtests.jl
julia teaching-assistant unit-testing
Last synced: about 15 hours ago
JSON representation
Test utilities with scoring.
- Host: GitHub
- URL: https://github.com/stepanzh/scoredtests.jl
- Owner: stepanzh
- License: mit
- Created: 2022-08-02T19:50:35.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-08-26T13:42:50.000Z (about 2 years ago)
- Last Synced: 2024-10-12T22:11:31.058Z (24 days ago)
- Topics: julia, teaching-assistant, unit-testing
- Language: Julia
- Homepage:
- Size: 23.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ScoredTests.jl
ScoredTests.jl is a tiny package providing
- `@scoredtest expr [award] [penalty] [name]` macro;
- and `ScoredTestSet([description])`.The macro evaluates an expression giving result of the test: was it passed, failed or errored during testing.
When a test is passed, it gives `award`, when failed or errored it takes `penalty`.
Tests (and testsets) can be grouped into `ScoredTestSet`-s via `*=` orepand.
## MWE
```julia-repl
julia> using ScoredTests
julia> ts = ScoredTestSet("Basic math");
julia> ts2 = ScoredTestSet("Trigonometry");
julia> ts2 *= @scoredtest sin(x)^2 + cos(x)^2 == 1;
julia> ts2 *= @scoredtest sin(10)^2 + cos(10)^2 == 1;
julia> ts2 *= @scoredtest sin(-1) / cos(-1) == tan(-1) name="Tangent definition";
julia> ts *= ts2;
julia> ts3 = ScoredTestSet("Quadratic polynomials");
julia> ts3 *= @scoredtest (1 + 2)^2 == 1^2 + 2*1*2 + 2^2 name="Square of sum" award=5;
julia> ts3 *= @scoredtest (1 - 2)^2 == 1^2 + 2*1*2 + 2^2 name="Square of difference";
julia> ts3 *= @scoredtest 3^2 - 4^2 == (3 - x)(3 + x) penalty=2;
julia> ts *= ts3;julia> printsummary(ts)
Basic mathTrigonometry
No. Result Score [Name] [Error]
1 E -1 Error occured: UndefVarError(:x)
2 ✓ 1
3 ✗ -1 Tangent definitionQuadratic polynomials
No. Result Score [Name] [Error]
4 ✓ 5 Square of sum
5 ✗ -1 Square of difference
6 E -2 Error occured: UndefVarError(:x)Summary
Passed 2 test(s) of 6 [33.3%] and 2 of test(s) throw(s) exception(s)
Achieved 1 point(s) of 10 [10.0%]
```## Use case
Originally, the package is supposed to be used by teachers and student in the following manner
Teacher perspective
- Create a repo (or template) of package, containing task and scored testset.
Student perspective
- Clone the repo, complete task, check score via `julia --project=Project.toml test/runtests.jl` or from REPL `pkg>` mode.