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

Improve naming conventions for test methods. #44

Open
2 tasks
tacosontitan opened this issue Apr 13, 2024 · 0 comments
Open
2 tasks

Improve naming conventions for test methods. #44

tacosontitan opened this issue Apr 13, 2024 · 0 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed refactor Something about the code could be better

Comments

@tacosontitan
Copy link
Owner

tacosontitan commented Apr 13, 2024

The currently defined test methods don't clearly articulate what is actually being tested, which is critical given the indirect and sometimes rather obscure naming of the methods utilized to achieve terse code to levels that are competitive with more golf-friendly languages. Take the tests for the methods for generating ranges for example:

[Fact]
public void GR_SingleParam_Generates_Correct_Range()
{
    var count = 5;
    var result = Gr(count);
    Assert.Equal(Enumerable.Range(1, count), result);
}

For starters, this fully-underscored naming convention needlessly extends the name and adds little to no value. That can be simplified to separating the method, condition, and result; for example, the method above could be simplified to:

public void GR_SingleParam_GeneratesCorrectRange();

Additionally, the GR here isn't as useful as it could be from a maintenance perspective. Instead, let's expand the name to its more legible representation GenerateRange. While it doesn't match the actual method being tested, it helps developers maintaining the project better understand the code they're working with:

[Fact]
public void GenerateRange_SingleParameter_GeneratesCorrectRange()
{
    var count = 5;
    var result = Gr(count);
    Assert.Equal(Enumerable.Range(1, count), result);
}

This issue covers the correction of the test methods defined in:

@tacosontitan tacosontitan added help wanted Extra attention is needed good first issue Good for newcomers refactor Something about the code could be better labels Apr 13, 2024
@tacosontitan tacosontitan pinned this issue Apr 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed refactor Something about the code could be better
Projects
None yet
Development

No branches or pull requests

1 participant