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

Unit tests: Global reference to userID across multiple Analytics instances #1066

Open
cprince-foreflight opened this issue Oct 28, 2024 · 0 comments

Comments

@cprince-foreflight
Copy link

I have some unit tests that use Analytics to carryout some testing. Some of these create the Analytics objects in static members. i.e., so the Analytics object is effectively global, scoped to those test cases. This has worked well so far, but I'm running into an issue.

In a new test, I wanted to get a new instance of Analytics and I assumed the userId would be nil. That's part of what I'm testing. Since, in that XCTestCase class hadn't initialized it. i.e., I hadn't done an identify call. However, the other XCTestCases test do those identify calls, and happen to get initialized first across all the test targets of my Swift package.

It looks like Analytics shares a global value for userId across Analytics instances. This is making my testing a bit tricker than I would have expected. Not sure if this is operating as expected or not.

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

No branches or pull requests

1 participant