2012-07-30 28 views
2

我正在与Mink/Sahi一起为我的网站编写功能测试套件。针对我们网站的功能测试

我有一组测试通过他们使用Firefox和Chrome,我很满意。他们每晚都在我们的詹金斯盒子上跑步,并且运作良好。

但是,因为我们的Jenkins盒子是服务器,Chrome/Firefox是GUI应用程序,所以我不得不在我的台式电脑上运行测试。这是一个痛苦,因为这意味着我必须每晚都打开它,这对环境和成本的原因是不利的。此外,如果它在电源或网络或软件方面有任何问题,则测试失败。

因此,我想在切换测试在Jenkins盒本身上使用无头浏览器的建议。

看来我有三种选择:Goutte,Zombie和Phantom(当然除非任何人可以推荐另一种)。下面总结了我迄今取得的进展:

  • GOUTTE:这是PHP驱动的,所以会水貂内运行,消除了对SAHI公司的需要。这听起来不错,因为詹金斯盒子的资源有限,所以我需要安装和运行的越少越好。但是,我需要将JS代码作为测试的一部分来运行,并且我知道Goutte无法做到这一点。这是否排除?

  • 僵尸:在Node.js下运行。不幸的是,我一直无法完成这项工作。我已经安装了Node,NPM和Zombie,但我无法让Mink识别它。任何人都可以给我一些比Mink网站更清晰的指导,告诉我如何让这个运行?

  • 幻影:不幸的是,Mink没有Phantom的驱动程序,所以我必须通过Sahi运行它。正如我所说的,我宁愿不必在Jenkins服务器上安装Sahi,特别是因为它也需要作为服务器连续运行。但这是迄今为止我唯一取得成功的一个。在Sahi下运行它,我可以让我的测试成功运行(虽然不是一致的,这是一个担心 - 它似乎随机超时,大约三分之一)。任何人都可以提出一种不需要安装Sahi(或任何其他中间层服务器)就可以运行的方法吗?或者如果我确实需要Sahi,谁能告诉我如何配置Jenkins在测试套件开始时启动Sahi并在最后停止它?

我真的很感激任何关于如何进行的建议。由于某种原因,这些选择似乎都没有明显的胜利。但是功能测试很重要,所以这一定是一个解决的问题。对我来说最好的解决办法是什么? (我知道还有一种方法是在Javascript中重写我的脚本,直接与僵尸或Phantom对话,我不想这样做,因为当它们失败时,我仍然需要看到它们在Firefox中运行看看发生了什么问题,所以像Mink这样的跨浏览器界面是理想的 - 更不用说我已经用PHP编写了所有测试!)

感谢您的任何建议。 :)

回答

2

这个答案是专门为

谁能告诉我如何詹金斯配置在 begining测试套件的开始SAHI公司,并在年底停止吗?

使用Ant,你可以使用以下目标

<target name="sahitests" description="start the server and run sahi tests"> 
    <parallel> 
     <antcall target="start"/> 
     <sequential> 
      <waitfor maxwait="3" maxwaitunit="minute" checkevery="100"> 
       <http url="http://${urlbase}/demo/index.htm"/> 
      </waitfor> 
      <antcall target="runietests"/> 
      <antcall target="stopsahi"/> 
     </sequential> 
    </parallel> 
</target> 

<target name="start" description="starts proxy"> 
    <java classname="net.sf.sahi.Proxy" fork="true"> 
     <classpath location="lib/sahi.jar"> 
      <pathelement location="extlib/rhino/js.jar"/> 
      <pathelement location="extlib/apc/commons-codec-1.3.jar"/> 
      <pathelement location="extlib/license/truelicense.jar"/> 
      <pathelement location="extlib/license/truexml.jar"/> 
      <pathelement location="extlib/db/h2.jar" /> 
      <pathelement location="extlib/poi/dom4j-1.6.1.jar"/> 
      <pathelement location="extlib/poi/excelpoi.jar"/> 
      <pathelement location="extlib/poi/poi-3.7-20101029.jar"/> 
      <pathelement location="extlib/poi/poi-ooxml-3.7-20101029.jar"/> 
      <pathelement location="extlib/poi/poi-ooxml-schemas-3.7-20101029.jar"/> 
      <pathelement location="extlib/poi/xmlbeans-2.3.0.jar"/> 
      <fileset dir="extlib" includes="*.jar"/> 
     </classpath> 
     <arg value="." id="basePath"/> 
     <arg value="userdata" id="userdataPath"/> 
    </java> 
</target> 

<target name="runietests"> 
    <antcall target="clean-tests"> 
    </antcall> 
    <sahi suite="../userdata/scripts/demo/demo.suite" 
      browserType="ie" 
      baseurl="http://${urlbase}/demo/" 
      sahihost="localhost" 
      sahiport="9999" 
      failureproperty="sahi.failed" 
      haltonfailure="false" 
      threads="6" 
      > 
     <report type="html"/> 
     <report type="junit" logdir="${userdata.dir}/temp/junit/tests"/> 
    </sahi> 
    <antcall target="report-gen" /> 
    <antcall target="failsahi"/> 
</target> 

<target name="report-gen"> 
    <delete dir="${userdata.dir}/temp/junit/reports"> 
    </delete> 
    <mkdir dir="${userdata.dir}/temp/junit/reports"/> 
    <junitreport todir="${userdata.dir}/temp/junit/reports"> 
     <fileset dir="${userdata.dir}/temp/junit/tests"> 
      <include name="TEST-*.xml" /> 
     </fileset> 
     <report format="frames" todir="${userdata.dir}/temp/junit/reports/sahi-html" /> 
    </junitreport> 
</target> 

<target name="failsahi" if="sahi.failed"> 
    <antcall target="stopsahi"/> 
    <fail message="Sahi tests failed!"/> 
</target> 


<target name="stopsahi" description="stop sahi server"> 
    <sahi stop="true" sahihost="localhost" sahiport="9999"/> 
</target> 

重要的位是

  1. “sahitests” 目标这将启动SAHI公司和 并行运行测试开始SAHI公司。
  2. “启动”目标,无需仪表板启动Sahi。

您可以在Sahi论坛上的Sahi + PhantomJS中发布随机故障问题以获得答案。

作为代理服务器的Sahi的开销/占用空间相当小。

+0

谢谢你的回答。非常感谢。我会给你的想法一个去;他们听起来很有趣。而且我现在也会接受答案,甚至在我尝试过之前,因为它看起来应该是我正在寻找的东西,即使它不适合我,它肯定会教我一些东西!谢谢。 – SDC 2012-08-06 08:40:56