Skip to content
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

Merged
merged 5 commits into from
Nov 8, 2024
Merged

Conversation

majakusber
Copy link
Contributor

@majakusber majakusber commented Nov 7, 2024

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)

@majakusber majakusber self-assigned this Nov 7, 2024
* Indicates the method being tested in the annotated test method. Diffblue Cover attaches this
* annotation to all tests that it creates.
*/
@Retention(RUNTIME)
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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
@majakusber majakusber force-pushed the maja/methodundertest branch from 9f955c3 to ca586b0 Compare November 7, 2024 16:37
Copy link
Contributor

@roxspring roxspring left a 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;
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor Author

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 {
Copy link
Contributor

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.

Copy link
Contributor Author

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
@majakusber majakusber merged commit 51e87fb into develop Nov 8, 2024
1 check passed
@majakusber majakusber deleted the maja/methodundertest branch November 8, 2024 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants