-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Enable multiple test suites and test configurations in the Test UI #12075
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
Comments
Thank you for the suggestion! We have marked this issue as "needs decision" to make sure we have a conversation about your idea. We plan to leave this feature request open for at least a month to see how many 👍 votes the opening comment gets to help us make our decision. |
My use case is running different subsets of tests with different environment variables or command line arguments (either would be fine, cli arguments preferred). I have tests structured in the following fashion:
Each require different settings. Subpaths within each folder structure can also require specific settings. It seems like the launch configuration concept for debugging and tasks would serve for test configurations. I have no idea how that would extend out to the Testing panel or the lenses. |
I would love this as well. Ideally a way to to define our configurations for testing and venv's by the file path of each file. so one doesn't have to toggle different venvs per file via the GUI each time they start vscode. one way i could envision this is doing something similar to the way TASKS are configured. by way of example here is is a current day example from my {
"python.testing.cwd": "${workspaceRoot}",
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.testing.pytestArgs": ["daemon"]
} it would be amazing if even just these configureations could be nested list of dicts, the way task are in with the only difference being I would propose allowing some sort either a "global config" or a "order matters fall through configuration" (since file paths could match multiple splats) rough draft, maybe something like: "python.testing.configurations": [
{
"name": "default tests",
"files": "**/*", all files would match this by default, so when you are in this workspace, this is the first set of configs you get
"cwd": "${workspaceRoot}",
"unittestEnabled": false,
"pytestEnabled": true,
"pytestArgs": [],
},
{
"name": "specific tests for foo",
"files": "${workspaceRoot}/foo/**/*",
"cwd": "${workspaceRoot}/foo",
"pytestArgs": ["-vv"],
"venv": "${workspaceRoot}/.venv/foo", // use the `foo` venv for tests in foo
},
{
"name": "specific tests for bar",
"files": "${workspaceRoot}/bar/**/*",
"cwd": "${workspaceRoot}/bar",
"pytestArgs": ["-rxXs"],
"venv": "${workspaceRoot}/.venv/bar", // use the `bar` venv for tests in bar
},
] the main problem i see with this is you WOULD have to spawn multiple invocations of python & pytest/unittest for each unique set of configurations but then again thats exactly what we are asking for ;) |
since this is actually something i would ultimately want not just for |
+1 My use case is that vscode testing integration doesn't support debugger with pytest running tests in parallel with pytest-xdist. So workaround would be having one configuration for debugging, one for performance parallel testing. |
Are there any updates on this? Thanks |
Hello! There are no updates on this feature request at this time. It has received the necessary number of votes to move into our backlog and once we are working on it, will we tag this issue in our iteration plan. If you are passionate about this feature request we always welcome community contributions and also prioritize feature requests with a high number of likes so you can also work to increase the upvotes. Thanks! |
Just to throw in my use case for this feature - Monorepos and anything resembling them are very problematic. We have a django project that includes several different websites which largely share the same common core, but have modifications to them and their own django settings.
To run our tests we specify which settings file we want to run
In our case pytest get's upset because it finds tests in all of the projects, but only has the settings to run one of the projects correctly. My understanding is that I can't have multiple test configurations that specify the settings for each project? IntelliJ handles this very well:
This allows you to do a bunch of things:
Currently VSCode's implementation appears to be a single global setting for each test type per workspace? So there's only a single configuration for pytest tests. I'd love to see this added to VSCode. |
I would also love to have this feature in vscode. I already "liked" the opening post, here is my usecase. I have to run pytests with various options (ordinary unit tests, UI tests with selenium - for multiple browsers, with code coverage, etc.). In the CI pipeline, there are separate jobs for each of these, but in local development, "copy-pasting" or "commenting/uncommenting" the
|
this is related to this general discussion, linking so people can follow along and comment on that discussion: #21845 |
Thank you. Added a comment over there. I saw it mentioned a different config for discover/run but one thing I didn't see captured over there was multiple configs for different configs for different types of "run" Over on 21845 I've added that multiple configs are important for things like mono-repos, which need unique configs for different paths, but it is also important for things like libraries supporting multiple python versions and wanting to test across multiple versions. Having a single config as opposed to a list of configs, and having a single interpreter (that's not even part of settings.json) instead of a list of interpreters, limits the usable scope to workspaces that can need a single interpreter. |
great point yes- thank you for your in-depth comment on the other post and we will take this into consideration as we move to create what it might actually look like. Thanks! |
Hello, I have a use case akin to the ones talked in here. I'm using pytest, and I run my tests in parallel with this snippet in [tool.pytest.ini_options]
addopts = [
"--numprocesses=auto"
] When debugging a single test with the ad-hoc button shown bellow, pytest spawns as many workers as CPU threads I have, which the debugger analyses, which add few seconds of extra delay before the test runs. My current workflow is to change the entries |
I think this is related: |
Problem Statements
P1. Currently VS Code for Python only allows a single test configuration for each test framework. For example, using PyTest, I can apply certain arguments to run whenever PyTest is run through the UI, but if I setup that configuration to exclude certain tests (such as those annotated with "slow"), I have to manually update the arguments in the options window to switch to another configuration.
P2. There is also no way to setup separate groups of tests and show them in the Test sidebar window as those groups. For example, rather than having a module-based hierarchy, it would be great to have the ability to have them grouped by arbitrary groups of modules/classes/methods and/or based on annotations. Currently one cannot have the tree show different groups of test, such as those annotated as "slow" or "sanity".
P3. In addition, any tests that are excluded by the current test configuration cannot be run even when they are directly selected to run as an individual test, because the current configuration causes them to be excluded by the test framework. So that one test will be detected, but then excluded from running. So if I normally want to exclude "slow" tests, that means I cannot even click directly on a slow test and run it directly in the UI.
Current Elements in the UI:
Use Cases
Use cases for allowing creation and easy selection of multiple test groupings and configurations:
Requirements
AS A VS Code user writing larger python programs and packages with tests
I NEED a way to create and run different test suites for a given program or package, that are not solely based on modules or test classes, and to run them under varying sets of arguments or test configurations
SO THAT
@pytest.mark
annotationConcepts
Allow a file or some GUI (perhaps directly in the VS Code options) that defines a test configuration.
a. Optionally, separate test groupings (i.e. slow, sanity, etc.) from other test options
b. Options would include any argument that can be fed to the test framework, such as running coverage, the output type of the coverage, different test framework settings.
c. These settings would supersede the current "test arguments" option in VS Code that is present for each of the individual test frameworks, which would be consider the "default" test configuration for all tests.
Allow the user to select the current test configuration from a dropdown or similar UI element
a. Likely in the sidebar window, perhaps on a separate line just under the header row that says "Python".
b. Such a dropdown is envisioned to work like the Run/Debug dropdown in VS Code where you can either select an existing test configuration or create a new one, through an entry always present at the bottom of the list.
c. Alternately, or in addition, there could be an annotation that allows switching configurations that is inline, or at least that is an inline link that opens whereever configurations are selected in the sidebar (or in VS Code options).
Reorganize the test hierarchy in the sidebar window based on test configurations options that could use module, test class, and/or annotations to specify how to create the test tree.
Provide a means of applying different default test configurations to different sets of test groups. For example, under concept 3, the user is already defining different test suites or groups of tests, the user should also have some means of changing the default configuration for that group (or maybe the only configuration for that group?)
Acceptance Criteria
The user is able to setup multiple test configurations in terms of the test arguments that will be used when running any tests in the current test framework (unittest, pytest, nose, etc.).
User designated test groups
a. The user is able to setup multiple test suites or test groups that show up in the Test sidebar window based on:
b. If a test is included in multiple suites, it will show up in each of them
c. A separate category shows all tests not included in any other custom test groups, if any are specified (i.e. "other" category)
d. A separate category, "all", always shows all tests in the current module-based hierarchy format
The user is able to run or debug any single test directly with either the default test configuration, or a test configuration specifically setup for running individual tests.
A given test suite or configuration would allow for running an external script that runs the test framework (with all appropriate arguments), rather than running the framework directly by VS Code.
The user is able to select a "current test configuration" that is used instead of the default test configuration, and is used for any case where a group or test doesn't have a configuration specified
The text was updated successfully, but these errors were encountered: