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

Provide a @FailAt annotation #549

Open
helpermethod opened this issue Nov 29, 2021 · 9 comments
Open

Provide a @FailAt annotation #549

helpermethod opened this issue Nov 29, 2021 · 9 comments

Comments

@helpermethod
Copy link

helpermethod commented Nov 29, 2021

Inspired by https://twitter.com/mikeveerman/status/1464162014444638258

It would be nice to provide an annotation that fails at a specified date, with on optional reason. Something like this:

@FailAt(date = "2022-01-01", reason = "An optional reason")
@Test
void should_fail_at_the_provided_date() {
    // ...
}

This could be a great way to remind oneself of unpaid technical debt but could probably also be used in other contexts.

@Michael1993
Copy link
Member

What's the upside of the annotation over this one-liner:

assumeTrue(LocalDate.now().isBefore(2022,1,1), "An optional reason"); // or assertTrue if you want the test to fail, not abort

@Michael1993
Copy link
Member

Hm, I guess, you could say that this assumption/assertion is meta - it's not really an assertion or assumption that is part of the test and therefore should be moved out from the method body? 🤔

@helpermethod
Copy link
Author

@Michael1993 Exactly, IMHO it should be separate from the actual assertions.

An annotation would also give you a visual clue that this is something you need to be aware of, and makes searching for the existence of such tests simpler (e.g. by grepping for the annotation).

But maybe the annotation is too esoteric to be included in JUnit Pioneer 😄 .

@Michael1993
Copy link
Member

But maybe the annotation is too esoteric to be included in JUnit Pioneer 😄 .

Not at all! Our @ReportEntry annotation uses the same reasoning (report entries are meta and not part of the test), so this would be a great fit for Pioneer.
Let me know if you want to implement this yourself or if we should go ahead and make it ourselves.

@helpermethod helpermethod changed the title Provide an @FailAt annotation Provide a @FailAt annotation Nov 29, 2021
@helpermethod
Copy link
Author

Hi @Michael1993,

I can take a stab at it 🙂!

@Bukama
Copy link
Member

Bukama commented Dec 2, 2021

Hm I see this is the same as DisableUntil annotation #366.

edit: @Michael1993 explained me the difference.

@Bukama
Copy link
Member

Bukama commented Dec 4, 2021

We talked about this at our last team meeting and want you to invite to take part in a discussion to think about this and similar use cases in a more global view.

Feel free to write down your thoughts and ideas in #550 - thank you!

@nipafx
Copy link
Member

nipafx commented Apr 28, 2022

Since this seems to overlap a lot with #366 and #550, I'll close this as a duplicate. Feel free to comment of you disagree.

@nipafx
Copy link
Member

nipafx commented Apr 28, 2022

Ooops, not so much of a duplicate after all. 😊 Still, let's first discuss in #550.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants