0

有什么方法可以使用 ANT 迁移工具生成 salesforce unittests html 报告?

参考:https ://github.com/beamso/force-deploy-with-xml-report-task

我尝试将 junitreportdir 附加到 testLevel="RunLocalTests" 但得到不受支持的错误,如下所示:

**[root@ip-10-1-1-15 unit_test]# ant ValidateRunAllTestsReport

构建文件:/opt/salesforce/ANT_Migration_Tool/unit_test/build.xml ValidateRunAllTestsReport:构建失败 /opt/salesforce/ANT_Migration_Tool/unit_test/build.xml:33:sf:deploy 不支持“junitreportdir”属性总时间:2 秒**

下面是我完整的 build.xml

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

<property file="build.properties"/>
<property environment="env"/>

<!-- Setting default value for username, password and session id properties to empty string 
     so unset values are treated as empty. Without this, ant expressions such as ${sf.username}
     will be treated literally.
-->
<condition property="sf.username" value=""> <not> <isset property="sf.username"/> </not> </condition>
<condition property="sf.password" value=""> <not> <isset property="sf.password"/> </not> </condition>
<condition property="sf.sessionId" value=""> <not> <isset property="sf.sessionId"/> </not> </condition>

<taskdef resource="com/salesforce/antlib.xml" uri="antlib:com.salesforce">
    <classpath>
        <pathelement location="../ant-salesforce.jar" />            
    </classpath>
</taskdef>
<!-- Shows check only; never actually saves to the server -->
<target name="ValidateRunAllTests">
    <sf:deploy username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" deployRoot="${sf.srcFolder}" checkOnly="true" testLevel="RunLocalTests"/>
</target>
<path id="ant.additions.classpath">
    <fileset dir="/opt/salesforce/ANT/apache-ant-1.10.7"/>
</path>
<target name="ValidateRunAllTestsReport">
    <taskdef
                name="sfdeploy"
                classname="com.salesforce.ant.DeployWithXmlReportTask"
                classpathref="ant.additions.classpath"
                />
    <delete dir="test-report-xml" quiet="true"/>
    <sf:deploy username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" deployRoot="${sf.srcFolder}" checkOnly="true" testLevel="RunLocalTests" junitreportdir="test-report-xml"/>
</target>   

4

1 回答 1

0

我在我的环境中有这个工作

<target name="deployAndTestAndReport" depends="generic_build_tasks">
    <taskdef
            name="sfdeploy"
            classname="com.salesforce.ant.DeployWithXmlReportTask"
            classpath="lib/ant-salesforce.jar;lib/force-deploy-with-xml-report-task.jar"
    />
    <delete dir="test-report-xml" quiet="true"/>
    <sfdeploy
            username="${sf_deploy_username}"
            password="${sf_deploy_password}"
            serverurl="${sf_deploy_url}"
            deployRoot="src"
            maxPoll="${sf.maxPoll}"
            pollWaitMillis="${sf.pollWaitMillis}"
            testLevel="RunLocalTests"
            junitreportdir="test-report-xml"
            checkOnly="true"
    >
        <!-- Run only tests with file names that match this pattern -->
        <!--<batchtest>
            <fileset dir="src/classes">
                <include name="*Test.cls"/>
            </fileset>
        </batchtest>-->
    </sfdeploy>
</target>
于 2020-07-23T05:15:00.707 回答