I am using a build.xml(ant) and code looks as follows,
<junit fork="yes" dir="." >
----------
---------
<for list="1,2,3,4,5,6" param="Val">
<env key="environment" value="${Val}" />
<batchtest fork="yes" todir="${junitreport.todir}">
<fileset dir="src/java">
<include name="TestOne.java" />
<include name="TestTwo.java" />
</fileset>
</batchtest>
</for>
</junit>
while running this i get the following error,
junit doesn't support the nested "for" element.
Is there any other way to achieve this loop in junit?
Please help.
Swap the <for>
and the <junit>
elements so <for>
is on the outside and <junit>
is on the inside:
<for list="1,2,3,4,5,6" param="Val" delimiter=",">
<sequential>
<junit ...>
<!-- Use an at-sign to reference the "param" from "for". -->
<env key="environment" value="@{Val}" />
</junit>
</sequential>
</for>
Note, that Val
is referenced as @{Val}
with an at-sign (@
), not a dollar sign ($
).