-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add a new annotation @MethodUnderTest #13
Conversation
* Indicates the method being tested in the annotated test method. Diffblue Cover attaches this | ||
* annotation to all tests that it creates. | ||
*/ | ||
@Retention(RUNTIME) |
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.
💡 Techincally, we need this only at source level - we're only using this as some kind of meta-data for the combiner and related code.
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.
Won't we be reading it from bytecode classes, therefore needing at least class retention?
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.
Nope, this is purely on the source code level. Remember this goes only into test classes, and we obviously have those files (since we write them!). No need to look at bytecode here.
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.
Ok, updated
Defined in a new subpackage "generated" to emphasise that this is not to be used by the user but assigned by Diffblue Cover itself. Using runtime retention - as I'm not sure is class would be enough for our purposes. The value parameter has no default value, to make sure that the annotation is only ever used with a value. Note: some of the other annotations are repeatable, this one should not be (only one annotation per test method should be used)
This info is only needed on source code level
9f955c3
to
ca586b0
Compare
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.
There are bike sheds we could discuss but technically this looks correct 😉
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
package com.diffblue.cover.annotations.generated; |
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.
Certainly makes sense to separate this from others which provide "testing advice". I can't quite decide whether I like .generated
but I don't have an obvious improvement to offer.
I would ask where we think @MaintainedByDiffblue
or whatever will live and consider matching it, but I think we concluded not to bother with that.
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.
Thank you, I'm also undecided about the name but can't think of a better one. Perhaps @peterschrammel might help?
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 moved it to the main package with the other ones, Javadoc explains the difference enough (pointed out by Johannes and Rob) and the name "generated" is I guess more questionable than whether it's a new package or not. Peter was also more on the side of keeping it in the same package. End of bike shed 😄
*/ | ||
@Retention(SOURCE) | ||
@Target(METHOD) | ||
public @interface MethodUnderTest { |
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.
❓ @MethodUnderTest
vs @MethodsUnderTest
? I'm slightly inclined to add the s
since it supports multiple values... but I'm also aware that the singular case will be most common.
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 will change this to plural, now I see the ticket was defined like that as well
Javadoc explains the difference between this one and the testing-advice-ones enough, and "generated" was questionable
Defined in a new subpackage "generated" to emphasise that this is not to be used by the user but assigned by Diffblue Cover itself (hence no README change either). Using runtime retention - as I'm not sure is class would be enough for our purposes. The value parameter has no default value, to make sure that the annotation is only ever used with a value.
Note: some of the other annotations are repeatable, this one should not be (only one annotation per test method should be used)