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

[BUG] Java-Piscine / AgeFinder subject / Test is requiring wrong result #2843

Open
liogedz opened this issue Jan 17, 2025 · 0 comments
Open
Assignees
Labels

Comments

@liogedz
Copy link

liogedz commented Jan 17, 2025

Describe the bug

Test requiring incorrect result if running between The 01 January untill end of February each year.
It has hardcoded line adding 2 months of age every begining of the year:
at this line ( int expected = LocalDate.now().getYear() - 2000;)

    @Test
    void testCalculateAge_withEdgeCases() {
        // Edge case: Leap year
        String date = "2000-02-29";
        int expected = LocalDate.now().getYear() - 2000;
        assertThat(ageFinder.calculateAge(date))
                .withFailMessage("Expected age to be %d but got %d", expected, ageFinder.calculateAge(date))
                .isEqualTo(expected);
        // Edge case: Minimum valid date
        String minDate = "0001-01-01";
        int minExpected = LocalDate.now().getYear() - 1;
        assertThat(ageFinder.calculateAge(minDate))
                .withFailMessage("Expected age to be %d but got %d", minExpected, ageFinder.calculateAge(minDate))
                .isEqualTo(minExpected);
    }

Users

Every student running Java-Piscine between above mentioned dates (01 Jan - 28 Feb) each year.
For a present moment test is ensuring person with DOB 2000-02-29 is 25 yo.

Severity
Choose the severity label (⚠️ critical).

Type
Choose the label (⚙️ functionality)

To Reproduce

Run the test within those mentioned dates

Workarounds

Hardcode is the only way to pass it for a moment.

Expected behavior

Test should require actual age instead of overaged.

Attachments

Image

Desktop (please complete the following information):

Ubuntu 24.04.1 LTS

Smartphone (please complete the following information):

NA

Additional context

@liogedz liogedz added the 🐞 bug Bug label Jan 17, 2025
@liogedz liogedz changed the title [BUG] Java-Piscine / AgeFinder subject / Test required wrong result [BUG] Java-Piscine / AgeFinder subject / Test is requiring wrong result Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants