1

我试图让所有文件名通过某个过滤器以进入由空格分隔的单个变量。

这有效:

<foreach item="File" property="filename">
        <in>
            <items>
                <include name="bin\*Test.dll" />
                <include name="bin\*Tests.dll" />
            </items>
        </in>
        <do>
            <echo>Executing serverSideTests</echo>
            <tstamp />
            <exec basedir="${devenv.dir}" program="VSTest.Console.exe" commandline='"${filename}" /TestCaseFilter:"TestCategory!=Debugging|TestCategory!=Upgrade"' failonerror="true" />
            <tstamp />
        </do>
    </foreach>

我想运行这个:

VSTest.Console.exe file1 file2 ...

我为什么要执行上述操作是,结合上述操作,我将使用 runsettings 来并行化上述不同的测试集。

如何将文件名连接成一个空格分隔的字符串?

4

1 回答 1

2

自己想通了,结果证明,如果不直观的话,它很容易:

<property name="testAssemblies" value=""></property>

<target name="test">
    <call target="clientSideTests" />
    <foreach item="File" property="filename">
        <in>
            <items>
                <include name="bin\*Test.dll" />
                <include name="bin\*Tests.dll" />
            </items>
        </in>
        <do>
            <property name="testAssemblies" value='${testAssemblies} "${filename}"'></property>
        </do>
    </foreach>
    <echo>Executing serverSideTests for ${testAssemblies}</echo>
    <tstamp />
    <exec program="${devenv.test}\VSTest.Console.exe" commandline='${testAssemblies} /TestCaseFilter:"TestCategory!=Debugging|TestCategory!=Upgrade" /Settings:"vstest.runsettings"' failonerror="true" />
    <tstamp />
于 2016-10-18T09:46:03.830 回答