Skip to content

Ability to run single test methods or classes #209

@giampaolo

Description

@giampaolo

This is a common use case, supported both by unittest and pytest. E.g. in unittest I can run an individual test method with:

python3 -m unittest somelib.tests.test_process.TestProcess.test_kill

With pytest:

python3 -m pytest mylib/tests/test_process.py::TestProcess::test_kill

Apparently with UnitTesting it's possible to specify a single test module to run, but not a test class or a test method.
Right now I am running individual test modules by using this build config:

    "build_systems": [
        {
            "name": "Sublime tests:",
            "target": "unit_testing",
            "package": "mypackage",
            "variants": [
               {"name": "test_create_snippet_from_sel.py",  "pattern": "test_create_snippet_from_sel.py"},
            ]
         }

I would like to be able to specify something like (mimicking pytest style):

 {"name": "test_kill",  "pattern": "test_create_snippet_from_sel.py::TestProcess::test_kill"},

To give even more context about my specific use case: I have a dynamic build system able to run individual test methods based on the cursor position (see ST forum post). I did this for both pytest and unittest. I would like to do the same by using UnitTesting.

@randy3k if you like the idea I can try working on a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions