Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
feat: Update instrumentation generator #1094
feat: Update instrumentation generator #1094
Changes from 2 commits
ac75f31
eb1fb05
04c1112
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't able to run these tests locally. When I tried to run the file from the root directory using:
I got the following error:
It looks like
mocha
hasn't updated its call toMiniTest::Assertion
to use theMinitest
spelling. Minitest used to accept both spellings, but now it only acceptsMinitest
.Minitest has its own stubbing features that can be used, though you have to use them in a specific test and can't set them in a
setup
method. Here's one of my favorite articles on stubbing in Minitest: https://semaphoreci.com/community/tutorials/mocking-in-ruby-with-minitestWhen I removed
mocha/minitest
and took the@generator.stubs
method calls out of thesetup
method, I was able to run the tests.The only error I got was related to calling
puts
:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since running the generator creates files, I think the files should be deleted between the tests to make sure we have a clean slate for each test.
Like the
setup
method you added, minitest also has ateardown
method.Maybe in
teardown
we could delete the directory we expect to get created if it exists?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First off, thank you for adding tests! It's great to have coverage on a tool that we use whenever we add new instrumentation.
I like this example as the three options a Ruby unit test should evaluate1:
In this test, it's almost as if we're testing whether the
@generator.template
method can be called. Since we don't define@generator.template
, (that's fromThor
), I think we could take a different approach to make sure everything is working as expected.Of the three options listed above, I think we want to make sure this method causes a side effect.
Since the
root_files
method is supposed to create these files from the ERB templates, what if we checked to see if the files were created when the method is run?That could look like:
assert File.exist?('instrumentation/new_instrumentation/.yardopts')
Let me know if you want help brainstorming assertions related to side effects of the other methods.
Footnotes
https://www.cloudbees.com/blog/unit-testing-in-ruby#what-should-be-tested ↩