From f476d38a0b98a44b8c4dbdce2478f5c2dc4e11cb Mon Sep 17 00:00:00 2001 From: "adarsh.ramakrishna" Date: Mon, 18 Jul 2016 16:15:49 -0700 Subject: [PATCH] Changes related to better README file --- README.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7d85540..4271010 100644 --- a/README.md +++ b/README.md @@ -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 /services/oauth2/token -d "grant_type=password" -d "client_id=****************" -d "client_secret= **************" -d "username=***********" -d "password= *******" +curl -v /services/oauth2/token -d "grant_type=password" -d "client_id=*CLIENT_ID_GOES_HERE*" -d "client_secret= *CLIENT_SECRET_GOES_HERE*" -d "username=*yourusername@yourdomain.com*" -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 ++ 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: @@ -36,7 +36,12 @@ curl -v /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. + - 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" - 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" @@ -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.