Skip to content

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

Closed

Description

@incendial

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.

Activity

  1. added
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    on Oct 5, 2023
  2. added this to the On Deck milestone on Oct 9, 2023
  3. added
    in commandsRelates to commands (usually invoked from the command Palette)
    on Oct 9, 2023
  4. DanTup commented on Oct 9, 2023

    @DanTup
    Member

    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.

  5. incendial commented on Oct 9, 2023

    @incendial
    Author

    Looks like there are 3 options: do nothing, new setting or a separate command 🤔

  6. DanTup commented on Oct 16, 2023

    @DanTup
    Member

    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).

  7. modified the milestones: On Deck, v3.86.0 on Mar 1, 2024
  8. modified the milestones: v3.86.0, v3.88.0 on Apr 2, 2024
  9. 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in commandsRelates to commands (usually invoked from the command Palette)is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions