Skip to content

Testing Dataloader

ashitsalesforce edited this page Jun 13, 2022 · 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 test -DtargetOS=<macos_x86_64 | macos_arm_64 | windows_x86_64 | linux_x86_64>

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 [-v <version number such as 52.0.0>] [-d] [-t <test class name>] <targetOS> <test org URL> <system admin username> <standard user username> <encrypted password>

NOTE: targetOS has to be one of macos_x86_64, windows_x86_64, macos_arm_64, linux_x86_64

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 -v <version> for example -v 52.0.0, if you want to test with an older version of WSC.

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 modifying maven - all platforms

Modify POM.XML

Pass the below arguments to maven or modify the pom.xml (just don't check the modified pom.xml in!)

<test.endpoint>SERVER URL</test.endpoint>

<test.user.default>ADMIN LOGIN NAME</test.user.default>

<test.user.restricted>NONADMIN LOGIN NAME</test.user.restricted>

<test.password>ENCRYPTED PASSWORD</test.password>

These tests encompass the core unit tests and all integration tests

$ mvn clean test -Pintegration-test -DtargetOS=<macos_x86_64 | windows_x86_64 | macos_arm_64 | linux_x86_64>

Note: -DtargetOS specifies the OS platform on which code is compiled and tests are run.

Note: New tests will be added to this list by default. Please edit pom.xml to exclude work's in progress. Look for the exclude list in the integration-test profile or the below text:

<!-- INTEGRATION UNIT TESTS: revise to remove works in progress -->

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

Clone this wiki locally