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

Test date #13198

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

GabrielSMonteiro
Copy link

@GabrielSMonteiro GabrielSMonteiro commented Jan 18, 2025

[#XXXX] Implementar testes adicionais para o método isValidStartEndDate

Fixes #XXXX

Resumo da Solução

Para resolver este problema, implementei testes adicionais para o método isValidStartEndDate da classe FeedbackSessionsLogic. As principais alterações incluem:

  1. Adição de novos casos de teste para cobrir cenários não testados anteriormente.
  2. Implementação de testes para verificar comportamento em casos limítrofes.
  3. Garantia de cobertura completa de todas as condições do método.

Os novos testes incluem:

  • Verificação de datas de início e fim iguais
  • Teste de data de início logo antes da data de fim
  • Verificação dos anos limite (1970 e 9999)
  • Testes para anos imediatamente antes de 1970 e após 9999

Essas adições garantem uma cobertura mais abrangente e robusta do método isValidStartEndDate, melhorando a confiabilidade do código.

Implementação dos Testes

@Test
public void testIsValidStartEndDate() {
    FeedbackSessionsLogic logic = FeedbackSessionsLogic.inst();
    ZoneId timeZone = ZoneId.of("UTC");

    // CT1: TestNullStartDate
    assertFalse(logic.isValidStartEndDate(null, Instant.parse("2023-12-31T23:59:59Z"), timeZone));

    // CT2: TestNullEndDate
    assertFalse(logic.isValidStartEndDate(Instant.parse("2023-01-01T00:00:00Z"), null, timeZone));

    // CT3: TestNullTimeZone
    assertFalse(logic.isValidStartEndDate(Instant.parse("2023-01-01T00:00:00Z"), Instant.parse("2023-12-31T23:59:59Z"), null));

    // CT4: TestValidDates
    assertTrue(logic.isValidStartEndDate(Instant.parse("2023-01-01T00:00:00Z"), Instant.parse("2023-12-31T23:59:59Z"), timeZone));

    // CT5: TestStartDateAfterEndDate
    assertFalse(logic.isValidStartEndDate(Instant.parse("2023-12-31T23:59:59Z"), Instant.parse("2023-01-01T00:00:00Z"), timeZone));

    // CT6: TestStartYearBefore1970
    assertFalse(logic.isValidStartEndDate(Instant.parse("1969-12-31T23:59:59Z"), Instant.parse("2023-12-31T23:59:59Z"), timeZone));

    // CT7: TestEndYearAfter9999
    assertFalse(logic.isValidStartEndDate(Instant.parse("2023-01-01T00:00:00Z"), Instant.parse("10000-01-01T00:00:00Z"), timeZone));

    // CT8: TestStartDateEqualEndDate
    assertFalse(logic.isValidStartEndDate(Instant.parse("2023-01-01T00:00:00Z"), Instant.parse("2023-01-01T00:00:00Z"), timeZone));

    // CT9: TestStartDateJustBeforeEndDate
    assertTrue(logic.isValidStartEndDate(Instant.parse("2023-01-01T00:00:00Z"), Instant.parse("2023-01-01T00:00:01Z"), timeZone));

    // CT10: TestStartYear1970
    assertTrue(logic.isValidStartEndDate(Instant.parse("1970-01-01T00:00:00Z"), Instant.parse("2023-12-31T23:59:59Z"), timeZone));

    // CT11: TestEndYear9999
    assertTrue(logic.isValidStartEndDate(Instant.parse("2023-01-01T00:00:00Z"), Instant.parse("9999-12-31T23:59:59Z"), timeZone));

    // CT12: TestStartYearJustBefore1970
    assertFalse(logic.isValidStartEndDate(Instant.parse("1969-12-31T23:59:59Z"), Instant.parse("2023-12-31T23:59:59Z"), timeZone));

    // CT13: TestEndYearJustAfter9999
    assertFalse(logic.isValidStartEndDate(Instant.parse("2023-01-01T00:00:00Z"), Instant.parse("10000-01-01T00:00:00Z"), timeZone));
}

Esta implementação cobre todos os cenários necessários para garantir uma cobertura MC/DC completa do método isValidStartEndDate.

Copy link

Hi @GabrielSMonteiro, thank you for your interest in contributing to TEAMMATES!
However, your PR does not appear to follow our contribution guidelines:

  • Title must start with the issue number the PR is fixing in square brackets, e.g. [#<issue-number>]
  • Description must reference the issue number the PR is fixing, e.g. Fixes #<issue-number> (or Part of #<issue-number> if the PR does not address the issue fully)

Please address the above before we proceed to review your PR.

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.

1 participant