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

Document unit-test naming convention #64

Open
applejag opened this issue Jul 12, 2021 · 0 comments
Open

Document unit-test naming convention #64

applejag opened this issue Jul 12, 2021 · 0 comments
Labels
documentation Improvements or additions to documentation prio/1 Low priority. "Nice to have"

Comments

@applejag
Copy link
Contributor

Our unit tests are not that coherent in their names. We use a mix of different naming conventions, as they are written by different developers.

The simple answer is just to name them:

func Test{NameOfTypeOrFunction}(t *testing.T)

// Example
func Add(a, b int) int

func TestAdd(t *testing.T)

But it gets diffuse when we start having multiple tests targetting the same function/type/method but with slight variations.

An example format of this (though not that great IMO):

func Test{NameOfTypeOrFunction}_{StateOfType}_{ExpectedResult}(t *testing.T)
func TestAdd_GivenNegativeValues_ReturnsNegative(t *testing.T)

Suggest to write an RFC of this.

@applejag applejag added the documentation Improvements or additions to documentation label Jul 12, 2021
@applejag applejag added the prio/1 Low priority. "Nice to have" label Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation prio/1 Low priority. "Nice to have"
Projects
None yet
Development

No branches or pull requests

1 participant