Skip to content

Conversation

@rli
Copy link
Contributor

@rli rli commented Dec 13, 2024

~30 tests fail on initial run but succeed on automatic retry due to improper mockk cleanup

License

I confirm that my contribution is made under the terms of the Apache 2.0 license.

@rli rli requested a review from a team as a code owner December 13, 2024 23:55
@github-actions
Copy link

github-actions bot commented Dec 14, 2024

Qodana Community for JVM

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at [email protected]

@rli
Copy link
Contributor Author

rli commented Dec 14, 2024

resolved ~15, but still failing TelemetryHelperTest and some others

@rli
Copy link
Contributor Author

rli commented Jan 10, 2025

MockTelemetryServiceExtension does not work as expected, needs follow-up

@rli rli merged commit effbebd into main Jan 10, 2025
15 checks passed
@rli rli deleted the rli/fix-mockk-cleanup branch January 10, 2025 23:14
karanA-aws pushed a commit to karanA-aws/aws-toolkit-jetbrains that referenced this pull request Jan 17, 2025
Will-ShaoHua added a commit that referenced this pull request Jan 21, 2025
…owing NotAMockException (#5258)

## Description
<!--- Describe your changes in detail -->
<!--- If appropriate, providing screenshots will help us review your contribution -->
<!--- If there is a related issue, please provide a link here -->
Now there are 2 ways to use NoOpTelemetryService
1. if devs are not interested in validating the metric contents, don't need do anything as default test implementation is NoOpTelemetryService
2. if devs are interested in the metric contents, can use `MockTelemetryServiceExtension` which will inject a spy of batcher and replace the original test implementation in junit before hook and revert it in after hook so that you can use ArgumentCaptor to capture what's going through the batcher


Relevant #5207 

### root cause:
Originally by doing `class NoOpTelemetryService : TelemetryService(publisher, spy(DefaultTelemetryBatcher(publisher))) {`, it's not 100% guaranteed that the TelemetryBatcher passed in is a mockito spy, and it result in `NotAMockException` thrown from these cases.

### solution
Manually inject spy batcher separately in a different step instead of IDE doing the work when initializing app/project service components---------

Co-authored-by: Richard Li <[email protected]>
karanA-aws pushed a commit to karanA-aws/aws-toolkit-jetbrains that referenced this pull request Jan 22, 2025
karanA-aws pushed a commit to karanA-aws/aws-toolkit-jetbrains that referenced this pull request Jan 22, 2025
…owing NotAMockException (aws#5258)

## Description
<!--- Describe your changes in detail -->
<!--- If appropriate, providing screenshots will help us review your contribution -->
<!--- If there is a related issue, please provide a link here -->
Now there are 2 ways to use NoOpTelemetryService
1. if devs are not interested in validating the metric contents, don't need do anything as default test implementation is NoOpTelemetryService
2. if devs are interested in the metric contents, can use `MockTelemetryServiceExtension` which will inject a spy of batcher and replace the original test implementation in junit before hook and revert it in after hook so that you can use ArgumentCaptor to capture what's going through the batcher


Relevant aws#5207 

### root cause:
Originally by doing `class NoOpTelemetryService : TelemetryService(publisher, spy(DefaultTelemetryBatcher(publisher))) {`, it's not 100% guaranteed that the TelemetryBatcher passed in is a mockito spy, and it result in `NotAMockException` thrown from these cases.

### solution
Manually inject spy batcher separately in a different step instead of IDE doing the work when initializing app/project service components---------

Co-authored-by: Richard Li <[email protected]>
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