<commit_before>Apex Test Plus for Force.com Migration Tool
===========================================
\[[Japanese version](README_ja.md)\]

Introduction
------------
Apex Test Plus for Force.com Migration Tool is a custom Ant task to make testing Apex programs easier and faster that works with Force.com Migration Tool.  
This will significantly improve the productivity of Apex development, especially when this is used with Force.com IDE (Eclipse), and help you implement TDD(Test Driven Development).  
With Apex Test Plus, the following features, that are not provided by Force.com Migration Tool nor Force.com IDE, become possible:

* to save test results
* to visualize code coverage
* to view a specific part of debug log that is associated with each test method

Clone or download this repository and open `doc/sample_result/index.html` in a web browser. You can see a sample test result that Apex Test Plus actually generated.  
To know Force.com Migration Tool, see the [Force.com Migration Tool Guide](http://www.salesforce.com/us/developer/docs/daas/index.htm).


Installation
------------

1. Install Force.com Migration Tool (and Ant). Force.com Migration Tool versions that were confirmed to work with Apex Test Plus are 21.0 through 28.0.
1. Download [Apache Commons Lang](http://commons.apache.org/lang/download\_lang.cgi), version 2.6 or newer, and extract `commons-lang-`*version*`.jar` in it. Or you can simply use `lib/commons-lang-2.6.jar` bundled with Apex Test Plus
1. Copy `commons-lang-`*version*`.jar` and `ant-apextestplus.jar` into your Ant installation `lib/` directory.


Creating build.xml
------------------
The easist way to create a proper build.xml would be to start with the sample build.xml and build.properties that come with Force.com Migration Tool.  
At first, open build.xml and add an attribute setting, **xmlns:apextestplus="antlib:com.force.jp.ant.apextestplus"**, to the "project" root element as follows.

    <project name="Sample usage of Salesforce Ant tasks" default="test" basedir="." xmlns:sf="antlib:com.salesforce" xmlns:apextestplus="antlib:com.force.jp.ant.apextestplus">

The name of Ant task to run tests is **runTest**.

Some sample definitions, that will match typical cases, are shown below.

### Retrieving the Latest Source Files from the Server
Using the following task definitions, Apex source code (classes and triggers) are always retrieved from the server just before tests are ran.  
This is the most secure way to correctly generate visual code coverage results because source code may be changed by anyone else on the server.

    <property name="outDir" value="test_result"/>
    <property name="srcDir" value="${outDir}/src"/>

    <target name="runTest" depends="cleanOutDir,bulkRetrieveClasses,bulkRetrieveTriggers"><commit_msg>API version 31.0 is now verified<commit_after>Apex Test Plus for Force.com Migration Tool
===========================================
\[[Japanese version](README_ja.md)\]

Introduction
------------
Apex Test Plus for Force.com Migration Tool is a custom Ant task to make testing Apex programs easier and faster that works with Force.com Migration Tool.  
This will significantly improve the productivity of Apex development, especially when this is used with Force.com IDE (Eclipse), and help you implement TDD(Test Driven Development).  
With Apex Test Plus, the following features, that are not provided by Force.com Migration Tool nor Force.com IDE, become possible:

* to save test results
* to visualize code coverage
* to view a specific part of debug log that is associated with each test method

Clone or download this repository and open `doc/sample_result/index.html` in a web browser. You can see a sample test result that Apex Test Plus actually generated.  
To know Force.com Migration Tool, see the [Force.com Migration Tool Guide](http://www.salesforce.com/us/developer/docs/daas/index.htm).


Installation
------------

1. Install Force.com Migration Tool (and Ant). Force.com Migration Tool versions that were confirmed to work with Apex Test Plus are 21.0 through 31.0.
1. Download [Apache Commons Lang](http://commons.apache.org/lang/download\_lang.cgi), version 2.6 or newer, and extract `commons-lang-`*version*`.jar` in it. Or you can simply use `lib/commons-lang-2.6.jar` bundled with Apex Test Plus
1. Copy `commons-lang-`*version*`.jar` and `ant-apextestplus.jar` into your Ant installation `lib/` directory.


Creating build.xml
------------------
The easist way to create a proper build.xml would be to start with the sample build.xml and build.properties that come with Force.com Migration Tool.  
At first, open build.xml and add an attribute setting, **xmlns:apextestplus="antlib:com.force.jp.ant.apextestplus"**, to the "project" root element as follows.

    <project name="Sample usage of Salesforce Ant tasks" default="test" basedir="." xmlns:sf="antlib:com.salesforce" xmlns:apextestplus="antlib:com.force.jp.ant.apextestplus">

The name of Ant task to run tests is **runTest**.

Some sample definitions, that will match typical cases, are shown below.

### Retrieving the Latest Source Files from the Server
Using the following task definitions, Apex source code (classes and triggers) are always retrieved from the server just before tests are ran.  
This is the most secure way to correctly generate visual code coverage results because source code may be changed by anyone else on the server.

    <property name="outDir" value="test_result"/>
    <property name="srcDir" value="${outDir}/src"/>

    <target name="runTest" depends="cleanOutDir,bulkRetrieveClasses,bulkRetrieveTriggers">
{'fraction_non_alphanumeric': 0.10882300727853719, 'fraction_numerical': 0.005148233623291319, 'mean_word_length': 4.412103746397695, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 14}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7159231', 'n_tokens_mistral': 1551, 'n_tokens_neox': 1456, 'n_words': 684}