Skip to content
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

Detect use of "should" in tests and suggest statements rather than assertions #309

Open
mcmire opened this issue Jul 17, 2023 · 0 comments

Comments

@mcmire
Copy link
Contributor

mcmire commented Jul 17, 2023

There are two ways to name tests:

  • "should do such-and-such"
  • "does such-and-such"

Both styles are valid, but each communicates a slightly different message:

  • The first makes an assertion or expectation about the unit of code in question. It is prescriptive and tentatively describes an aspect of the system that is desired but may not be present. It speaks inwardly: it reflects a technical conversation between the programmer and the computer.
  • The second makes a statement about the unit of code. It is declarative and confidently describes an aspect of the system that is true today (whether or not that is true). It speaks outwardly: it reflects a more human conversation between the programmer and other programmers.

The extension and mobile teams have tended to use the first style; the Shared Libraries team, the Snaps team, and others tend to use the second style.

I propose that we implement an ESLint rule that checks for the first style and converts it to the second (or at least suggests that it be converted). We can apply this rule selectively to repos that already use the second style to ensure that they keep using it, and we can progressively add it to those that use the first style.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant