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

chore(java): write tests for most of the JavaIconProvider #146

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

thelooter
Copy link
Collaborator

Warning

This PR depends on #145 getting merged before

Description

This PR introduces the following changes:

  1. Added a new run configuration for running tests on the plugin project.
  2. Updated the Gradle dependencies to include the Mockito Kotlin library for testing.
  3. Added an internal getVisibilityIconForTesting method in the JavaIconProvider class to allow accessing the getVisibilityIcon method for unit testing purposes.
  4. Added unit tests for the JavaIconProvider class to cover various scenarios for icon provision, including:
    • Testing visibility icon provision for different access modifiers (public, private, protected, package-private)
    • Handling cases where the requested element is not a PsiClass or the file is not a Java file
    • Testing the behavior when Java support is disabled in the plugin settings

Motivation and Context

The main goal of this PR is to improve the testability of the JavaIconProvider class in the Catppuccin JetBrains Icons plugin. The previous implementation did not provide a way to directly test the getVisibilityIcon method, which is an important part of the icon provision logic.

By adding the internal getVisibilityIconForTesting method and creating a comprehensive set of unit tests, we can ensure that the visibility icon provision works as expected, which will improve the overall reliability and maintainability of the plugin.

How Has This Been Tested?

This PR includes a new test suite for the JavaIconProvider class, which covers the various scenarios mentioned in the description. The tests ensure that the visibility icon provision logic works as expected for different access modifiers.

Checklist

  • I have added tests to cover my changes.
  • All new and existing tests passed.

Signed-off-by: thelooter <evekolb2204@gmail.com>
@thelooter thelooter added the enhancement New feature or request label Nov 8, 2024
@thelooter thelooter self-assigned this Nov 8, 2024
Signed-off-by: thelooter <evekolb2204@gmail.com>
@sgoudham
Copy link
Contributor

sgoudham commented Nov 8, 2024

Added an internal getVisibilityIconForTesting method in the JavaIconProvider class to allow accessing the getVisibilityIcon method for unit testing purposes.

Afaik, this is a bit of an anti-pattern when you create methods just for testing purposes in your production code. Does Kotlin not have visibility levels similar to Java?

@thelooter thelooter changed the title feat(detekt): add detekt for static analysis and fix issues chore(java): write tests for most of the JavaIconProvider Nov 8, 2024
Signed-off-by: thelooter <evekolb2204@gmail.com>
@thelooter
Copy link
Collaborator Author

Added an internal getVisibilityIconForTesting method in the JavaIconProvider class to allow accessing the getVisibilityIcon method for unit testing purposes.

Afaik, this is a bit of an anti-pattern when you create methods just for testing purposes in your production code. Does Kotlin not have visibility levels similar to Java?

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants