如何关闭浏览器禁用 Ant Junit任务?我的代码允许在一个浏览器上运行测试(在会话中)。
当我从IDEA运行时,它通过1个浏览器运行我的测试,但是当通过Ant运行时,每次新测试运行时关闭并打开浏览器。
更新:以某种方式禁用拆解,我的测试没有拆卸
<target name="company" depends="build">
<mkdir dir="${junit.output.dir}"/>
<junit fork="yes" printsummary="withOutAndErr" showoutput="true" outputtoformatters="true" haltonfailure="no"
failureproperty="test.failed" haltonerror="no">
<sysproperty key="webdriver.browser" value="${webdriver.browser}"/>
<sysproperty key="project.config" value="${project.config}"/>
<formatter type="xml"/>
<test name="com.tests.MainHomePage" todir="${junit.output.dir}"/>
<test name="com.tests.company.AboutCompany" todir="${junit.output.dir}"/>
<classpath refid="seleniumproject.classpath"/>
<classpath refid="myWebDriver.classpath"/>
</junit>
<fail message="Test failure detected, check test results." if="test.failed"/>
</target>
答案 0 :(得分:0)
我发现解决方案需要添加forkmode="once"
,它将为整个Junit任务运行1个VM
示例:
<junit fork="yes" forkmode="once" printsummary="withOutAndErr" showoutput="true" outputtoformatters="true" haltonfailure="no"
failureproperty="test.failed" haltonerror="no">