2013-10-16 53 views
2

如何禁用Ant Junit任務從關閉瀏覽器?我的代碼允許在一個瀏覽器上運行測試(在會話中)。如何在新測試開始時關閉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

我找到解決方案需要添加forkmode="once",它將運行1 VM爲整個junit任務

例子:

<junit fork="yes" forkmode="once" printsummary="withOutAndErr" showoutput="true" outputtoformatters="true" haltonfailure="no" 
     failureproperty="test.failed" haltonerror="no">