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

Best Practices for Unit Testing with Salesforce Mobile SDK #3832

Open
dessmith opened this issue Feb 9, 2025 · 1 comment
Open

Best Practices for Unit Testing with Salesforce Mobile SDK #3832

dessmith opened this issue Feb 9, 2025 · 1 comment

Comments

@dessmith
Copy link

dessmith commented Feb 9, 2025

Hi Team,

First off, thanks for all the work on the Salesforce Mobile SDK! My team uses it in several of our apps, and it handles a lot of the heavy lifting for us when it comes to syncing and data management—so it’s a crucial part of our application.

As of now, our apps don’t have unit tests, and I’m looking to change that. However, I want to approach it in the correct way and ensure we're following best practices when testing code that depends on the SDK.

I couldn't find any guidance on this topic in the documentation or existing GitHub issues, so I wanted to ask:

How do you recommend users of the SDK design and write unit tests?
Should we mock the SDK components (e.g., SmartStore, SyncManager)? If so, do you provide any built-in ways to facilitate this?
Would it be feasible to create a copy of the database and use that for testing, or would that approach introduce complications?
Are there any example test cases or repos that showcase best practices for testing code that integrates with the SDK?
Any guidance on this would be really helpful as we work towards improving our test coverage.

Thanks!

@wmathurin
Copy link
Contributor

We do not have documentation specifically on that topic.
We could check out our tests in the repo - most are for testing the SDK directly but a few exercise sample apps using the SDK:

We also have UI tests which exercise the template apps that we offer through forceios/forcedroid etc:

Mocking can be tricky given our (over)reliance on singletons.
I would setup the data you need in your tests instead of copying a database which could lead to some challenges with encryption keys.

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

2 participants