GithubHelp home page GithubHelp logo

Comments (4)

sourcefrog avatar sourcefrog commented on August 27, 2024

I think it's good to make test names quite self explanatory, and therefore they will often be much longer than non-test function names. Even more than non-test code, if it seems like it needs a comment it's worth first making the name more explicit.

Quite possibly some of the existing names are too short as I've been increasingly come to feel this way about Rust this year.

I'm slightly against including "noise words" like "should", "when" and "given" just for the sake of a template because they use up more visual space than they are really semantically earning. error_when conveys as much information than should_return_error_when in half the space. The noise words make it harder to see the parts that vary. They're not "banned" but I am not sure it's useful to make a point of adding them.

list_mutants_well_tested_exclude_folder_filter 

So this one could be a bit longer, but it does have the advantage of including the command name list-mutants and the name of the tree (well_tested). I could go for something like list_mutants_in_well_tested_tree_exclude_folder.

copy_testdata_doesnt_include_build_artifacts

This too includes the name of the thing it's testing, the function copy_testdata, so you can search for it. I think that's better than rewriting it to when_testdata_is_copied, also shorter. If read as an English sentence it seems pretty clear.

error_when_no_mutants_found

Again this seems like a pretty clear though terse sentence (clause)? We could read them as assertions that something is true or something happens.

So overall:

  • thanks for the suggestion, I appreciate the thought you put into it
  • let's add something to CONTRIBUTING about making test names read like clear assertions when read aloud
  • I'm not convinced about those formulas being more than suggestions for how to form sentences
  • Let's fix any particular tests that have unclear names but maybe not necessarily rename everything

from cargo-mutants.

dmoka avatar dmoka commented on August 27, 2024

Absolutely, Martin!

It definitely not a critical issue, and it might be that I am biased a bit as I really got used to such standardized namings. When I first started working on the repo, and reading the tests, I had some difficulties due to the lack of such a naming template, that was the trigger to open this issue...

Anyway, small thing, and I also agree with some of your points you have. Without such template, we can still produce readable test names. It also shows that software engineering is not black and white. 🙂

Thank you too for your detailed input!

from cargo-mutants.

sourcefrog avatar sourcefrog commented on August 27, 2024

I added some advice on this in 8bc85a2.

Some existing tests might have unclear names and it would be fine to improve them along the lines discussed above if we're in the area. Bear in mind the Insta assertion files also probably need to be renamed.

I don't think this is worth keeping open as a bug in itself but I'm glad we talked about it.

from cargo-mutants.

dmoka avatar dmoka commented on August 27, 2024

Great addition with the test naming guidance, like it!

agree, we can close this issue.

from cargo-mutants.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.