Comments (4)
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.
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.
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.
Great addition with the test naming
guidance, like it!
agree, we can close this issue.
from cargo-mutants.
Related Issues (20)
- Follow `path` attribute on inline `mod` blocks HOT 5
- CI job that tests against some interesting/popular open source trees
- Try using a build profile that is quick but has no debug symbols
- More detail in CONTRIBUTING.md or the book about how to add new patterns
- Automatically merge results from multiple sharded jobs
- Test that requires copying `.git` HOT 3
- Support more cargo test flags HOT 2
- cargo-mutants doesn't work on tarpaulin tree HOT 1
- Check up on Debian packaging HOT 1
- Tests fail in unpacked crates.io crate tarball, due to missing testdata HOT 7
- Test building with the oldest allowed dependencies HOT 1
- Maybe force off cargo ansi colors in builds and tests
- `--jobs` has extra rebuilds of dependencies, causing build timeouts HOT 3
- Build fails when target file makes use of the include_str macro for reading data HOT 3
- Book site does not auto update on releases
- Test suite leaks rustc on `cargo_mutants_testdata_hang_when_mutated`
- Reconsider use of --cap-lints
- Unable to Set User Password via REST API in OpenDJ HOT 1
- Please update the crate fs2-0.4.0 to fs2-0.4.3
- Tests are running, but cargo-mutants detects 0 mutants to test
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cargo-mutants.