Skip to content
This repository was archived by the owner on Feb 12, 2022. It is now read-only.
Closed
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
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ Please refer https://github.com/forcedotcom/ApexUnit/wiki to know about the key
- 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*"
```
*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*

## How to build and execute?
- Clone the project onto your local system using the command:
Expand All @@ -35,7 +35,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
- 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.
Copy link
Contributor

Choose a reason for hiding this comment

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

use a number bullet over to '-'

- 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.
Copy link
Contributor

Choose a reason for hiding this comment

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

add source in?
"for the list of source classes for"

- 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"
- 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 @@ -79,7 +84,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"
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 Sample*Test,Sample*test -regex.for.selecting.source.classes.for.code.coverage.computation Sample*,Mobile*Controller,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"
Copy link
Contributor

Choose a reason for hiding this comment

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

can you say , your_regular_exp1, regular_exp2,... instead of Sample_Test,Sample_test where ever applicable?

Copy link
Contributor

Choose a reason for hiding this comment

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

```
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