Giter Club home page Giter Club logo

Comments (5)

chrispyles avatar chrispyles commented on May 27, 2024 1

So it's been a long time since this issue was opened but I think I've finally figured out a good schematic for a new test case format that relies on more traditional unit test-like formatting.

I'm thinking of a format that looks something like this:

from otter.test_files import test_case

name = "q1"
points = None

@test_case()
def test_sieve_1(env):
    assert env["sieve"](1) == set()

@test_case(name="q1b")
def test_sieve_2(sieve):
    assert sieve(2) == {2}

@test_case(name="q1c")
def test_sieve_3(sieve, env):
    assert sieve(3) == {2, 3}
    assert env["a"] == 1

@test_case(name="q1d", hidden=True)
def test_sieve_4(env):
    assert env["sieve"](20) == {2, 3, 5, 7, 11, 13, 17, 19}

@test_case(name="q1e", points=1, hidden=True)
def test_sieve_5(env):
    assert env["sieve"](100) == {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 
        61, 67, 71, 73, 79, 83, 89, 97}

The idea is similar to pytest, where a test fails if an exception is raised, and passes otherwise. The decorator is an object provided by Otter to store the test case metadata, and the student's global environment (or specific elements in it) are accessed through arguments to the test case functions.

from otter-grader.

chrispyles avatar chrispyles commented on May 27, 2024

Wow, this is really interesting, thanks! There have been some conversations recently about the limitations of the current testing format/framework for OK autograders (like what came up at the workshop) and so changing the testing format is something we might consider for a future release (v2?) as OkPy becomes more of a legacy solution and more classes get ported away from it.

Let's keep this thread open as a forum for considering this and other unit-testing frameworks as a method for writing Otter's tests!

from otter-grader.

choldgraf avatar choldgraf commented on May 27, 2024

πŸ‘ I bet they'd be excited to see testbook used in grading as well!

from otter-grader.

stale avatar stale commented on May 27, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

from otter-grader.

chrispyles avatar chrispyles commented on May 27, 2024

Implemeted in #376. This feature will be included in Otter v4.

from otter-grader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.