Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 14, 2025

The test class uses @RunWith(MockitoJUnitRunner::class), which automatically initializes @Mock annotated fields. The explicit MockitoAnnotations.openMocks(this) call was redundant and causing a compilation error.

Changes

  • Removed MockitoAnnotations.openMocks(this) from setup() method
  • Removed unused MockitoAnnotations import
@RunWith(MockitoJUnitRunner::class)
class WeatherWidgetRepositoryTest {
    @Mock
    private lateinit var context: Context
    
    @Before
    fun setup() {
-       MockitoAnnotations.openMocks(this)
        repository = WeatherWidgetRepository(context)
    }
}

Mock initialization is handled by the test runner annotation.

Original prompt

The build is failing with a compilation error in WeatherWidgetRepositoryTest.kt: Unresolved reference 'openMocks'.

This is because the @RunWith(MockitoJUnitRunner::class) annotation already handles the initialization of mocks, making the explicit call to MockitoAnnotations.openMocks(this) in the setup() method redundant and causing the error.

This pull request removes the unnecessary line MockitoAnnotations.openMocks(this) from android/app/src/test/java/com/luminlynx/misty/widget/WeatherWidgetRepositoryTest.kt to fix the build.

This pull request was created as a result of the following prompt from Copilot chat.

The build is failing with a compilation error in WeatherWidgetRepositoryTest.kt: Unresolved reference 'openMocks'.

This is because the @RunWith(MockitoJUnitRunner::class) annotation already handles the initialization of mocks, making the explicit call to MockitoAnnotations.openMocks(this) in the setup() method redundant and causing the error.

This pull request removes the unnecessary line MockitoAnnotations.openMocks(this) from android/app/src/test/java/com/luminlynx/misty/widget/WeatherWidgetRepositoryTest.kt to fix the build.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…RepositoryTest

Co-authored-by: LuminLynx <212206643+LuminLynx@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix build by removing redundant mock initialization Remove redundant MockitoAnnotations.openMocks() call in WeatherWidgetRepositoryTest Dec 14, 2025
Copilot AI requested a review from LuminLynx December 14, 2025 23:09
@LuminLynx LuminLynx marked this pull request as ready for review December 14, 2025 23:22
Copilot AI review requested due to automatic review settings December 14, 2025 23:22
@LuminLynx LuminLynx merged commit b7d9723 into main Dec 14, 2025
2 of 12 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a compilation error in the WeatherWidgetRepositoryTest by removing redundant Mockito mock initialization code. The test class uses @RunWith(MockitoJUnitRunner::class), which automatically initializes @Mock annotated fields, making the explicit MockitoAnnotations.openMocks(this) call unnecessary and causing an "Unresolved reference" error.

Key changes:

  • Removed redundant MockitoAnnotations.openMocks(this) call from the setup() method
  • Removed unused MockitoAnnotations import

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants