Skip to content
This repository was archived by the owner on Feb 12, 2022. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ Please refer https://github.com/forcedotcom/ApexUnit/wiki to know about the key
- Download link : https://maven.apache.org/download.cgi
- Installation instructions : https://maven.apache.org/install.html
- Configuring maven : https://maven.apache.org/configure.html
- Eclipse 3.6 or later
- OAuth setup for the org to get Client ID and Client Secret
- OAuth setup for the org to get Client ID and Client Secret using Connected App
- http://salesforce.stackexchange.com/questions/40346/where-do-i-find-the-client-id-and-client-secret-of-an-existing-connected-app
- http://stackoverflow.com/questions/18464598/where-to-get-client-id-and-client-secret-of-salesforce-api-for-rails-3-2-11
- http://www.calvinfroedge.com/salesforce-how-to-generate-api-credentials/
- Please verify the oauth setup for the org by executing the following command :
```shell
curl -v <Salesforce_Org_URL>/services/oauth2/token -d "grant_type=password" -d "client_id=****************" -d "client_secret= **************" -d "username=***********" -d "password= *******"
curl -v <Salesforce_Org_URL>/services/oauth2/token -d "grant_type=password" -d "client_id=*CLIENT_ID_GOES_HERE*" -d "client_secret= *CLIENT_SECRET_GOES_HERE*" -d "username=*[email protected]*" -d "password= *your_password_goes_here+*"
Copy link
Contributor

@vamshi-sfdc vamshi-sfdc Jul 19, 2016

Choose a reason for hiding this comment

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

should this be a encrypted/encoded password?

provide pointers on how encoding should be done?
does it hurt if you ask all users to use a encoded password?

```
*The above command should provide you the access_token in the response.*
*The above command should provide you the access_token in the response. If you have special characters in your password you will have to pass URL-encoded password plus the security token
+ If your password has special characters, you must pass in a URL encoded version of your password. Note that this only needs to be done for the curl command and not the maven command*

## How to build and execute?
- Clone the project onto your local system using the command:
Expand All @@ -36,7 +36,12 @@ curl -v <Salesforce_Org_URL>/services/oauth2/token -d "grant_type=password" -d "
```
This would create a local copy of the project for you.
- (Optional) Open the project in an IDE(eclipse, intelliJ etc.)
- Modify/Add manifest files for test classes (for execution) and for Apex(source) classes (for code coverage computation) in the following location in your project setup: src/main/resources
- There are two ways in which user can select the list of tests to execute and the lsit of classes to examine the code coverage
Copy link
Contributor

Choose a reason for hiding this comment

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

a flow chart would be useful in addition to this lengthy text. @glang

- regex - identify and provide regex for the test class names that you want to execute for the "-regex.for.selecting.test.classes.to.execute" parameter. Example: if you want to execute the tests: My_Apex_controller_Test, My_Apex_builder_Test and My_Apex_validator_Test, identify the regex as "My_Apex_\*_Test". Pass the parameter "-regex.for.selecting.test.classes.to.execute My_Apex_\*_Test" while executing the mvn command.
- Similarly, you can provide regex for the classes for which you want to examine the code coverage by using "-regex.for.selecting.source.classes.for.code.coverage.computation My_Apex_\*_Class" while executing the mvn command.
- Manifest files - List of tests can be read from Manifest files. Create a manifest file say ManifestFile_Unit_Tests.txt in "src/main/resources" location of your project. Add test names to execute in the manifest file. Specify this manifest file as "-manifest.files.with.test.class.names.to.execute ManifestFile_Unit_Tests.txt" while executing the mvn command.
- Similarly, add the class names for which you want to exercise code coverage in a manifest file say ClasssManifestFile.txt in "src/main/resources" location of your project and Specify this manifest file as "-manifest.files.with.source.class.names.for.code.coverage.computation ClassManifestFile.txt" while executing the mvn command.
- Note that multiple regexes and manifest files can be specified using comma seperation(without spaces). Example: "-regex.for.selecting.test.classes.to.execute This_Is_Regex1\*,\*Few_Test,Another_\*_regex -manifest.files.with.source.class.names.for.code.coverage.computation ClassManifestFile.txt,MoreClassesManifestFile.txt"
Copy link
Contributor

Choose a reason for hiding this comment

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

this item is rendered as third bullet. better markup?

- Go to your project directory(to the directory having pom.xml) in command prompt and execute the following command:
```java
mvn compile exec:java -Dexec.mainClass="com.sforce.cd.apexUnit.ApexUnitRunner"
Expand Down Expand Up @@ -86,7 +91,7 @@ Note: User must provide either of the (-regex.for.selecting.source.classes.for.c

Sample command:
```java
mvn compile exec:java -Dexec.mainClass="com.sforce.cd.apexUnit.ApexUnitRunner" -Dexec.args=" -org.login.url https://na14.salesforce.com -org.username test****@salesforce.com -org.password ****** -org.wide.code.coverage.threshold 75 -team.code.coverage.threshold 80 -org.client.id ******* -org.client.secret ***** -regex.for.selecting.test.classes.to.execute Sample*Test,Sample*test -regex.for.selecting.source.classes.for.code.coverage.computation Sample,Mobile,Wrapper -manifest.files.with.test.class.names.to.execute ManifestFile.txt -manifest.files.with.source.class.names.for.code.coverage.computation ClassManifestFile.txt -max.test.execution.time.threshold 10 -proxy.host your.proxy-if-required.net -proxy.port 8080"
mvn compile exec:java -Dexec.mainClass="com.sforce.cd.apexUnit.ApexUnitRunner" -Dexec.args=" -org.login.url https://na14.salesforce.com -org.username yourusername@salesforce.com -org.password yourpassword-org.wide.code.coverage.threshold 75 -team.code.coverage.threshold 80 -org.client.id CLIENT_ID_FROM_CONNECTED_APP -org.client.secret CLIENT_SECRET_FROM_CONNECTED_APP -regex.for.selecting.test.classes.to.execute your_regular_exp1_for_test_classes,your_regular_exp2_for_test_classes -regex.for.selecting.source.classes.for.code.coverage.computation your_regular_exp1_for_source_classes,your_regular_exp2_for_source_classes -manifest.files.with.test.class.names.to.execute ManifestFile.txt -manifest.files.with.source.class.names.for.code.coverage.computation ClassManifestFile.txt -max.test.execution.time.threshold 10 -proxy.host your.proxy-if-required.net -proxy.port 8080"
```
Note: Multiple comma separated manifest files and regexes can be provided.Please do not include spaces while providing multiple regex or manifest files.

Expand Down