Skip to content

Ability to write tests right in the same file #795

Open
@MahdiBM

Description

@MahdiBM

Description

It would be nice if we had the ability to write test in the same file, and not in files far away in a dedicated Tests folder.
This will have some benefits like:

  • The code and the tests are just simply closer apart.
  • We could use access modifiers like fileprivate to test parts of the code in the same file, instead of having to workaround this by @testable importing which makes users have to not use private access modifiers just to be able to test a function. Or using stuff like @_spi.

Languages like Rust do support this.

I saw some discussions about this a few months ago, I think the compiler needs to support better discovery of stuff like tests for this to be possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions