You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add a "Find Test/Implementation File" command that works like "Go to Test/Implementation" but opens file picker if no target file is found #4774
Is your feature request related to a problem? Please describe.
I have two cases where the test folder structure does not match the src/ folder structure.
1) One of the intermediate folders was omitted (ex. instead of test/impl/another/** all tests are put into test/another/**). Which looks easy to fix unless you have 1000 tests that need to be updated + some test rely on the relative file paths which makes it a bit problematic. Although, I agree that it's mostly the consequences of my bad decisions and should not probably be covered by the extension feature.
However, while investigating this I figured out there is another case:
2) Let's say I have a list of similar classes located in classes/ (ex. classes/some.dart, classes/another.dart, etc.), but in order to test these classes I need some additional data that cannot be placed inside the test file, but is expected to be close to the test file in order to be easily updatable, avoid any potential cross-test dependencies and so on. So the test files are all placed inside their own directories "classes/some/", "classes/another", etc. with their test data being in a separate inner folder. This makes the folder structure asymmetrical between the implementation and test files and the only way right now to make the "Go To Test File" command to work is to place each implementation file in their own directory and having multiple directories with only one file complicates the project structure.
Describe the solution you'd like
A way for the "Go To Test File" command to be able to open test files do not have the exact match of impl file FS path.
Describe alternatives you've considered
Another command or any other way to achieve that.
I started looking at this but realised that the request conflicts with #2650.
That issue says "if you can't find the test file, offer to create it at the expected location" but this issue says "if you can't find the test file, open the file picker searching for that name". Of course, we can only do one of these.
I don't really want to add a new setting to pick the behaviour when trying to jump to a test file that doesn't exist, but I haven't yet thought of a better way.
My feeling is that probably a new command will be best. In the same way that VS Code has things like "Go to Implementation" and "Find Implementations", we can have the existing "Go to Test/Implementation" command that will only jump if a match is found (but in the case of impl -> test we will still prompt) and a "Find test/implementation" command that will jump to them if there's a single obvious entry, but otherwise will back to opening a search with the filename (without/without the _test).
changed the title [-]Support locating test files without the exact folder structure match of the implementation files[/-][+]Add a "Find Test/Implementation File" command that works like "Go to Test/Implementation" but opens file picker if no target file is found[/+]on Apr 16, 2024
Activity
DanTup commentedon Oct 9, 2023
I started looking at this but realised that the request conflicts with #2650.
That issue says "if you can't find the test file, offer to create it at the expected location" but this issue says "if you can't find the test file, open the file picker searching for that name". Of course, we can only do one of these.
I don't really want to add a new setting to pick the behaviour when trying to jump to a test file that doesn't exist, but I haven't yet thought of a better way.
WIP: Support opening file picker when can't jump to test/impl file
incendial commentedon Oct 9, 2023
Looks like there are 3 options: do nothing, new setting or a separate command 🤔
DanTup commentedon Oct 16, 2023
My feeling is that probably a new command will be best. In the same way that VS Code has things like "Go to Implementation" and "Find Implementations", we can have the existing "Go to Test/Implementation" command that will only jump if a match is found (but in the case of impl -> test we will still prompt) and a "Find test/implementation" command that will jump to them if there's a single obvious entry, but otherwise will back to opening a search with the filename (without/without the
_test).WIP: Support opening file picker when can't jump to test/impl file
[-]Support locating test files without the exact folder structure match of the implementation files[/-][+]Add a "Find Test/Implementation File" command that works like "Go to Test/Implementation" but opens file picker if no target file is found[/+]