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

Add a test function to detect a memory leak if it it happened #3859

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

Conversation

kittisak-phetrungnapha
Copy link
Contributor

@kittisak-phetrungnapha kittisak-phetrungnapha commented Apr 5, 2024

Goals ⚽

Follow up from #3766, I create a test function to check that is RequestInterceptor has a memory leak or not. It's becoming this pull request because it could be used with other places as well.

Implementation Details 🚧

  • Add checkMemoryLeaks in BaseTestCase so that all subclassed test classes can use this function.
  • Add checking memory leaks testing for all tested functions in InterceptorTests class.

Example of memory leaks (It's just fake from me):
leak

Copy link
Contributor

@jshier jshier left a comment

Choose a reason for hiding this comment

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

Thanks, this seems like it could be useful. Just a couple small notes.

/// - object: The testing object for each class.
/// - file: Which file that failure test happens.
/// - line: Which line that failure test happens.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, *)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add explicit watchOS and visionOS support as well? I think the other OSes are on their own.

checkMemoryLeaksIfApplicable(interceptor)
}

private func checkMemoryLeaksIfApplicable(_ object: AnyObject, file: StaticString = #file, line: UInt = #line) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like this should just live in the BaseTestCase to allow for all tests to use it. And given we can't test back before iOS 13 anyway, I'm not sure the IfApplicable is really necessary here.

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.

None yet

2 participants