-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
launch.json "args" don't get passed to pytest unittests #12997
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. |
Is it documented somewhere how to pass arguments when running tests? And can it be configured both for Running and Debugging tests? |
@jepperaskdk |
@karthiknadig I was wondering if I could configure arguments for both running and debugging, individually. E.g. our integration tests can run non-headless with a browser which is useful when debugging a test that is failing. Also, is this issue valid? Is |
@jepperaskdk when it comes to testing using the testing UI, the launch.json support there is minimal. It can be used to send some additional flags to the debugger itself. But the args or other details vary test-to-test and even test-case-to-test-case. Configuring those for different scenarios is not supported if you depend on the test UI. But if you want to setup your project to run tests entirely via launch json, then you can have full control over every aspect of the test run. Just that you won't see any updates or changes in the test UI. If you are ok going down this route and looking at the results in the terminal, then you can configure tests like this:
You can pass any args, create any number of these configurations for each testing scenario, change terminal type, pass different env variables for testing vs running, etc. Just that the output will show up in the terminal. |
Some thoughts- I hadn't realized that configuring the test explorer via launch.json is something that you can already do, via the I would feel a little better about it if it was at least possible to create a config that could be used as a normal debug config and also could be plugged into the test explorer ui. Then a user would not have to duplicate their variables for running in two ways. But I can't get this to work, if I add In general I'd say that extensions shouldn't be reading and writing launch.json (or settings.json or other files that are managed by vscode). We provide API for interacting with these in the ways that we expect extensions to. I see #18778 that I'll keep thinking about it but I think it would be a better user experience for this configuration to live in settings.json where you can control every aspect of it and don't have to create a "dummy" launch config to hold data. Some inspiration is maybe the terminal profiles setting where you give a list of terminal profiles and define all of their attributes. You can have run/debug/discovery attributes right next to each other in a common format. The only difference is that debugging tests outside of the test explorer is still set up in launch.json. I am fine keeping the |
I came across this issue because we have some custom Another example use-case is that I might want to include the Thanks for thinking about this issue! I'm definitely hopeful that there's a highly flexible way to allow both intuitive and targeted configuration of these behaviors. |
Hi! We are redesigning how args work in relation to test run and debug. Follow along here: #20425 This should resolve the above problem and create a clear flow for args and debugging so please contribute your thoughts to the discussion if you have any. Thanks! |
Environment data
Expected behaviour
A configuration like the following:
should pass the arguments to pytest or the other testing framework used
Actual behaviour
Arguments get passed to pyvsc-run-isolated.py
Steps to reproduce:
Create a pytest compatible unit test
Create launch.json containing
Note: I took a look at the code that runs pyvsc-run-isolated.py and the launch.json args just aren't supported yet as far as I can tell. Would hopefully not be too much work for someone familiar with vscode internals.
The text was updated successfully, but these errors were encountered: