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

Implement @AutoClose Annotation #3368

Commits on Jun 24, 2023

  1. Implement @autoclose Annotation

    This commit introduces the @autoclose annotation, AutoCloseUtils class,
    and AutoCloseExtension class to enhance resource management in JUnit 5
    tests.
    
    The @autoclose Annotation:
    The @autoclose annotation is a custom annotation created in the
    org.junit.jupiter.api package. It can be applied to fields within JUnit
    5 test classes. This annotation indicates that the annotated resource
      should be automatically closed after test execution. It specifically
      targets ElementType.FIELD elements.
    
      AutoCloseUtils Class:
      The AutoCloseUtils class is added to the org.junit.jupiter.api
      package. It provides utility methods for automatically closing
      resources used in tests. The closeResources method takes a test
      instance as a parameter and closes all fields annotated with
      @autoclose within that instance.
    
      AutoCloseExtension Class:
      The AutoCloseExtension class is introduced in the
      org.junit.jupiter.api.extension package. It implements the
      AfterEachCallback interface and acts as a JUnit 5 extension. By using
      the @ExtendWith(AutoCloseExtension.class) annotation on test classes
      or methods, the extension invokes AutoCloseUtils.closeResources to
      automatically close resources annotated with @autoclose after each
      test execution.
    
      These changes aim to simplify resource cleanup in JUnit 5 tests,
      reduce boilerplate code, and enhance the readability of test code.
    
      Please review the introduced changes and provide any feedback or
      suggestions for improvement.
    ibrahimesseddyq committed Jun 24, 2023
    Configuration menu
    Copy the full SHA
    a92a1f6 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    9335b31 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    f2c3149 View commit details
    Browse the repository at this point in the history