Skip to main content

check50_junit

This is an extension for the CS50 automarker check50 for compiling and running Junit5 unit tests and raising the resulting failures directly as check50 Failures to be used in checks.

This module ships with Junit5's stand-alone console launcher.

Your problem set only needs to include the compiled bytecode of junit test classes, which are compiled against your model solution to the exercise. This gets around the issue that unit tests may not compile for student's code due to unexpected method signatures class identifiers. Such errors will be reflected in the JUnit's report XML file.

Example Usage

TLDR: import check50_junit; add your compiled junit test classes to your pset, and use check50_junit5.run_and_interpret_test within your checks. A full example follows.

All examples below assume that you're importing check50 and check50_junit.

  1. Write your model solution and unit test classes and manually compile them.

    public class Drink {
        private final int volume;
    
        public Drink(int v) {
            volume = v;
        }
    
        int getVolume() {
            return volume;
        }
    
    import static org.junit.jupiter.api.Assertions.*;
    import org.junit.jupiter.api.Test;
    
    class DrinkTest {
      @Test
      public void getVolume() {
        Drink d = new Drink(200);
        assertEquals(200, d.getVolume());
      }
    }
    
  2. Move the bytecode DrinkTest.class somewhere into your pset directory, say under tests/.

  3. Add a check as follows (I would usually have this depend on class exists, compiles, and can be instantiated checks).

    @check50.check()
    def drink_getVolume():
        """Test Drink.getVolume()"""
        check50_junit.run_and_interpret_test(
            classpaths=['tests/'],
            args=['--select-method', 'DrinkTest#getVolume'])
    

    This will run the precompiled unit test on the student submission, parse junit's XML report and raise any check50.Failures as appropriate for the result. In this case it would raise a check50.Mismatch exception if the assertEquals within the unit test is thrown.

  4. Make sure to add check50-java as a dependency in your pset's .cs50.yml:

    check50:
      dependencies:
        - check50-java
      files:
        - !exclude "*"
        - !include "*.java"
    

Metadata

Release files for check50-junit 0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for check50-junit 0.5
File Size Uploaded Provenance Actions
check50_junit-0.5.tar.gz 2.0 MB Without provenance Details for check50_junit-0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for check50-junit 0.5
File Interpreter ABI Platform Actions
check50_junit-0.5-py3-none-any.whl Python 3 none any Details for check50_junit-0.5-py3-none-any.whl

Total release size: 3.9 MB

Release files / check50_junit-0.5.tar.gz

Download URL check50_junit-0.5.tar.gz
Size 2.0 MB
Tags Source
SHA-256 checksum
How to use checksums
e6ec39c9a4b4155599c67bdbdc855c96e9e20a4b30bb167a9fe9f66afdeb3606
BLAKE2b-256 checksum
How to use checksums
4550d2cec50cfde27ac508eea20e74b5506613b1682a89a150c5c50a65588d63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release files / check50_junit-0.5-py3-none-any.whl

Download URL check50_junit-0.5-py3-none-any.whl
Size 2.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
4f766364fa67540b79f16681cb3b4c3362a2f2c4c56bb009c832e8f7a5548bad
BLAKE2b-256 checksum
How to use checksums
095bbe9c19ff0384dbdc237c5fbb9bc1ddbaf2a617ec36ed28cd0104066ea1a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Security for check50-junit 0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page