Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OK Writing and Running Tests #313

Merged
merged 18 commits into from
Aug 26, 2017
Merged

OK Writing and Running Tests #313

merged 18 commits into from
Aug 26, 2017

Conversation

khalilsarwari
Copy link
Contributor

@khalilsarwari khalilsarwari commented Jul 15, 2017

Addressing #63

This PR allows for OK to read and collect test files that users create independently.

Vision: An easy to use write/run testing setup with minimal interference from OK

The src files specified in the config.ok are crucial in deciding what gets tracked for coverage and what files are imported into the testing environment automatically.

The following run the tests in 'mytests.rst', unless another file is specified after -t:

Will return overall test coverage percent

    python3 ok -t
    python3 ok -t alttestfile.rst
    python3 ok -t -v --suite 1 --case 1

Will return overall test coverage percentage, as well as suggested lines to test

python3 ok -t -cov 

The hope now is to be able to include this so we could have students write their own tests for Ants. I know @papajohn was interested in having students be able to write tests, so I've requested his review here.

Example .rst student test file:

screen shot 2017-08-09 at 6 54 46 pm

@khalilsarwari khalilsarwari requested a review from epai July 15, 2017 04:02
@khalilsarwari
Copy link
Contributor Author

Looking forward to some feedback! (specifically regarding the PR or otherwise)

@epai
Copy link
Contributor

epai commented Jul 15, 2017

@khalilsarwari Hmm, it looks like some tests are failing. Can you check and make sure no tests fail when you run nosetests tests?

@epai
Copy link
Contributor

epai commented Jul 15, 2017

Ah, I think I see the reason. Make sure you push your support_files so your testing_test test cases pass.

epai
epai previously requested changes Jul 15, 2017
Copy link
Contributor

@epai epai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests must pass

@epai epai dismissed their stale review July 15, 2017 08:36

Tests now pass, will re-evaluate

@epai epai requested review from papajohn, kevinlin1 and knrafto July 15, 2017 08:36
@papajohn
Copy link
Contributor

That's very cool! Three things that we should consider:

  1. We should also support students adding doctests directly in their regular source files. I'm not sure what happens in OK if they do this now. (Does OK always run all doctests, or only when asked?)

  2. It would be nice to allow semantic names to suites and cases, instead of numbering. If the case numbering format is fixed, that's something to get wrong.

Lists:

    >>> master = [1, 2, 3]
    
    Pop:
        >>> master.pop()
        3
        >>> master.pop()
        2

    Extend:
        >>> master.extend([4, 5]) is None
        True
    
    ...
  1. Could we change all of our staff-written OK tests to this format? (Perhaps in a different PR.)

@khalilsarwari
Copy link
Contributor Author

After confirming with @epai :

  1. OK runs some of its tests from the doctests that come with the source file(s), as well as some independent tests. All the doctests are run by default, and deleting some lines/spaces can make OK tests not pass. The idea of running these doctests from the source file(s) may have been a result of the difficulty in writing OK tests in the ok_test format.
    If this difficulty were not a significant issue, a potential solution would be to make these doctests independent by converting what is necessary to ok_tests, thus enabling students to modify and create doctests in the source files. (Another potential solution could be 3., redoing ok_tests as a whole.)

  2. Support for semantic labels has now been added, and the overall format is actually pretty flexible, which I should clarify now. Suite 1 is fine, so is Suite Lists or Suite lists. So far, the only required format is Suite [/d/w]+ and Case [/d/w]+which I think is enough to parse with maximum freedom (comments, spacing etc).

  3. We could! We would just have to add support for WWPD and Scheme questions, as well as support for other functionality such as locking, hiding, and scoring. I can look into it after this PR.

@papajohn
Copy link
Contributor

papajohn commented Aug 15, 2017 via email

self.postcov.stop()
failed = rfailed
attempted = rattempted
passed = attempted - failed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why failed and attempted variables are created instead of just using failed and rattempted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I didn't catch that!

@khalilsarwari khalilsarwari merged commit 50d897e into master Aug 26, 2017
@epai epai deleted the khalil/tests branch September 3, 2017 02:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants