Skip to content

Testing Dataloader

ashitsalesforce edited this page Jun 4, 2023 · 25 revisions

You've made edits and want to test them out to see how they work.

1. Run the core unit tests

These tests do not require connectivity and are reasonably performant.

$ mvn clean package

Note: New tests will be added to this list by default. Please edit pom.xml to exclude the test if it requires connectivity. Look for the below text in the pom.xml and add an exclude pattern if appropriate.

<!-- CORE UNIT TESTS: revise to keep this list fast and connectivity free -->

2. Setup an org for integration tests

Integration tests require an active org with pre-configured environment values

Create an Org

Use an API enabled org. This includes developer orgs with the limitations listed at https://developer.salesforce.com/page/Developer_Edition

Customize the Account entity

  1. Navigate to Setup -> Customize -> Accounts -> Fields
  2. Account Custom Fields -> New (Create Account.AccountNumber Field)
  3. Set Data Type to "Text" -> Next
  4. Set Field Label to "AccountNumber"
  5. Set Length to "100" -> Next
  6. Next
  7. Save & New (Create Account.Oracle_Id Field)
  8. Set Data Type to "Text" -> Next
  9. Set Field Label to "Oracle_Id"
  10. Set External ID to true -> Next
  11. Set Length to "100" -> Next
  12. Next
  13. Save & New (Create Account.CustomDateTime Field)
  14. Set Data Type to "Date/Time" -> Next
  15. Set Field Label to "CustomDateTime" -> Next
  16. Next
  17. Save & New (Create Account.CustomDateOnly Field)
  18. Set Data Type to "Date" -> Next
  19. Set Field Label to "CustomDateOnly" -> Next
  20. Next
  21. Save & New (Create Account.Integration_Status field)
  22. Set Data Type to "Text" -> Next
  23. Set Field Label to "Integration_Status"
  24. Set Length to "20" -> Next
  25. Next
  26. Save & New (Create Account.RichText field)
  27. Set Data Type to "Text Area (Rich)" -> Next
  28. Set Field Label to "RichText"
  29. Next
  30. Save

Create a TestField custom entity

  1. Navigate to Create -> Objects
  2. New Custom Object (Create TestField Custom Entity)
  3. Set Label to "TestField"
  4. Set Plural Label to "TestFields"
  5. Save
  6. Custom Fields -> New (Create TestField.TestField Field)
  7. Set Data Type to "Text" -> Next
  8. Set Field Label to "TestField"
  9. Set External ID to true -> Next
  10. Set Length to "100" -> Next
  11. Next
  12. Save

Customize the Contact entity

  1. Navigate to Contacts -> Fields
  2. Contact Custom Fields -> New (Create Contact.NumberId Field)
  3. Set Data Type to "Number" -> Next
  4. Set Field Label to "NumberId"
  5. Set External ID to true -> Next
  6. Next
  7. Save & New (Create Contact.TestField Field)
  8. Set Data Type to "Lookup Relationship" -> Next
  9. Set Related to "TestField" -> Next
  10. Next
  11. Next
  12. Save

Create Hard Delete System Admin

  1. Manage Users -> Profiles
  2. Select "System Administrator" (It may be on the second page of profiles)
  3. Clone
  4. Enter the profile name "Data Loader Administrator"
  5. Save
  6. Edit
  7. Set "Bulk API Hard Delete" to true
  8. Save
  9. Manage Users -> Users
  10. New User
  11. Create new user with Profile "Data Loader Administrator"
  12. Make note of the user name
  13. Save

Create Non-Privledged Account

  1. Manage Users -> Users
  2. Create new user with Profile "Standard User" (On developer accounts, you may run out of licenses. If you do, try user license "Salesforce Platform" and profile "Standard Platform User".
  3. Make note of the user name
  4. Save

Setup passwords

  1. Activate both accounts with the same password
  2. Encrypt the password with Data Loader. This [jar] is the ./target/dataloader-*-uber.jar file

java -cp [jar] com.salesforce.dataloader.security.EncryptionUtil -e [PASSWORD]

Run the integration tests without modifying pom.xml through bash script - mac and linux

$ cd <root of data loader clone directory>
$ ./runtests.sh [-d] [-t <test class name>] <test org URL> <system admin username> <standard user username> <encrypted password>

NOTE: skip the prefix "com.salesforce.dataloader" when specifying test class name in the optional parameter -t. For example, specify -t dyna.DateConverterTest if you want to only do a test run of DateConverterTest.

NOTE: Specify -d to attach a remote debugger to the test run. The JVM running the tests is listening on port 5005.

Run the integration tests by invoking maven command - all platforms

$ mvn -Dtest.endpoint=<server URL> -Dtest.user.default=<admin login name> -Dtest.user.restricted=<non-admin login name> -Dtest.password=<encrypted password> clean verify

Subsequent runs

The tests clean up before and after runs but if the database is suspect, perform a mass delete on Accounts and Contacts, and TestField

Developing new tests

New tests will be added to the unit and integration test suites by default. If a test is an integration test (requires a server connection), exclude it from unit tests list by adding it to excluded tests in the unit tests section of pom.xml by looking for the line "".

To exclude an integration test from integration tests suite, look for the following text in pom.xml and add the test to exclude: <!-- Specify the list of integration tests to exclude -->