Project deployment, testing, and report generation

Deployment of source code, testing, and the following report generation is ensured by the special Ant task HPE force-deploy-task. In order to function, it is necessary to create the Ant build script “build.xml” (if it does not exist) in the root folder of a Force.com project similar to the following examples. See more details about attributes and elements in the table below.

  • The following example deploys source code to a configured Force.com environment and runs all tests. Because all tests will be run, the report should contain code coverage of the whole project.

    <project name="Sample usage of force-deploy-task" default=" deployAndTestAndReport " basedir=".">
    <target name="deployAndTestAndReport">
    <taskdef name="sfdeploy" classname="com.claimvantage.force.ant.DeployWithXmlReportTask"/>
    <delete dir="test-report-xml" quiet="true"/>
    <sfdeploy
    username="username to force.com environment"
    password="password to force.com environment"
    serverurl="force.com server URL"
    deployRoot="path to source directory"
    runalltests="true"
    reportDir=" test-report-xml " />
    </target>
    </project>
  • The following example deploys source code to a configured Force.com environment and runs only tests that match the given pattern. In this case, Agile Manager will not be provided full code coverage.

    <project name="Sample usage of force-deploy-task" default=" deployAndTestAndReport " basedir=".">
    	<target name="deployAndTestAndReport">
    		<taskdef name="sfdeploy" classname="com.claimvantage.force.ant.DeployWithXmlReportTask"/>
    		<delete dir="test-report-xml" quiet="true"/>
    		<sfdeploy
    		username="username to force.com environment"
    		password="password to force.com environment"
    		serverurl="force.com server URL"
    		deployRoot="path to source directory"
    		runalltests="false"
    		reportDir=" test-report-xml ">
    		<!-- Run only tests with file names that match this pattern -->
    		<batchtest>
    			<fileset dir="src/classes">
    				<include name="*Test.cls"/>
    			</fileset>
    		</batchtest>
    	</target>
    </project>

Description of the HPE force-deploy-task (in the example defined as sfdeploy):

username Attribute that defines the login name to the force.com environment
password Attribute that defines the password to the force.com environment
serverurl Attribute that defines the URL of the login page to the force.com environment
deployRoot Attribute that defines the path to the source code directory that contains classes, triggers, and so on.
runalltests

Attribute that defines whether tests are started and project code coverage is reported.

  • true: All tests are started and code coverage is reported
  • false: Only tests specified by batchtest element are started. Code coverage is not provided.
reportDir Attribute that defines where all reports will be stored.

batchtest

 

Element that specifies the tests that should be started. This works only if runalltests=false.

fileset Element that defines the file set of tests to run
 

dir

Attribute that defines the directory where the tests are located
 

include

Element that defines the classes of tests to run
    name Attribute that defines the class name pattern of tests to run