rubocop / minitest-style-guide

Best practices for writing your tests
https://minitest.rubystyle.guide
70 stars 15 forks source link

Any conventions for naming individual tests? #43

Closed codedeleter closed 2 years ago

codedeleter commented 2 years ago

Are there any good conventions for naming individual tests?

I'm used to rspec with describe "#method" and then a context "when blah blah" and then it "does the thing", which is a pretty easy kind of format to follow.

But I'm trying out minitest and I'm not sure how to do naming for def test_does_the_thing_when_blah

andyw8 commented 2 years ago

From what I observe, test names are typically brief and usually follow your example structure above. You can see this from Minitest's own tests:

https://github.com/seattlerb/minitest/blob/master/test/minitest/test_minitest_mock.rb

One difference from RSpec is that deeply nested contexts could result in very long test names in minitest. But I think this actually a good thing, as that often indicates a class has too much behaviour, and encourages refactoring.

andyw8 commented 2 years ago

Closing since it doesn't seem there any guidance to be added at this time.