microsoft / vscode-java-test

Run and debug Java test cases in Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-test
Other
292 stars 125 forks source link

Support when clauses for test configurations. #1627

Closed ReubenFrankel closed 8 months ago

ReubenFrankel commented 10 months ago

Is there a way to control what configurations are available to select when running tests in a specific package, class or method? I am aware there is a filters property, but as far as I can see this only supports JUnit tags (filters.tags) at the moment. I want to be able to filter by patterns (inspired by the Maven Surefire Plugin) - something like this:

settings.json

{
    "java.test.config": [
        {
            "name": "tests in specific package"
            "filters": {
                "pattern": "com.example.test"
            }
        },
        {
            "name": "tests not in specific package"
            "filters": {
                "pattern": "!com.example.test"
            }
        },
        {
            "name": "tests in specific class"
            "filters": {
                "pattern": "com.example.test.ExampleTests"
            }
        },
        {
            "name": "tests not in specific class"
            "filters": {
                "pattern": "!com.example.test.ExampleTests"
            }
        },
        {
            "name": "tests in a class of this name"
            "filters": {
                "pattern": "testExample"
            }
        },
        {
            "name": "not tests in a class of this name"
            "filters": {
                "pattern": "!ExampleTests"
            }
        },
        {
            "name": "this specific test"
            "filters": {
                "pattern": "com.example.test.ExampleTests#testExample"
            }
        },
        {
            "name": "not this specific test"
            "filters": {
                "pattern": "!com.example.test.ExampleTests#testExample"
            }
        }
    ]
}
jdneo commented 10 months ago

Sorry, it's not supported so far. I marked this issue as a feature request.