通过Ant运行Ruby测试(Rspec和Cucumber)

通过Ant运行Ruby测试(Rspec和Cucumber),ruby,ant,rspec,cucumber,teamcity,Ruby,Ant,Rspec,Cucumber,Teamcity,我目前正在研究TeamCity以及如何运行我们的Ruby测试。使用命令行或Rake生成器时,我可以很好地运行测试。我现在试图解决的问题有两个: 在我以前的一份工作中,我们还依赖TeamCity来运行.NET测试。为此,我们使用了Nant,我们有跟踪测试期间运行的查询量以及这些查询的平均执行时间的方法 我现在正试图用我的Ruby项目做同样的事情。因此,我想解决的第一个逻辑步骤是,如何使用Ant运行例如RSpec或Cucumber测试? 我试着观察Ant本身并稍微理解它,但我找到的所有示例都是针对j

我目前正在研究TeamCity以及如何运行我们的Ruby测试。使用命令行或Rake生成器时,我可以很好地运行测试。我现在试图解决的问题有两个:

在我以前的一份工作中,我们还依赖TeamCity来运行.NET测试。为此,我们使用了Nant,我们有跟踪测试期间运行的查询量以及这些查询的平均执行时间的方法

我现在正试图用我的Ruby项目做同样的事情。因此,我想解决的第一个逻辑步骤是,如何使用Ant运行例如RSpec或Cucumber测试? 我试着观察Ant本身并稍微理解它,但我找到的所有示例都是针对jRuby的,我们不使用它。我们依赖于RVM和正常的Ruby安装

问题的第二部分是,如何跟踪运行的查询量及其执行时间?我猜可能有一个gem用于跟踪它或某种全局变量。希望以某种方式将此信息输出回TeamCity

编辑

好的,所以我设法让我的TeamCity服务器运行Ant。 这是我使用的atm的XML:

   <?xml version="1.0"?>
   <project name="rubycas" default="init">
       <description>
           This buildfile is used to build the RubyCAS project under TeamCity and run the required tasks to validated
           whether the project is stable and fully functional.
       </description>
       <property name="test_type" value="cucumber" />

       <target name="init">
          <echo message="##teamcity[testStarted name='Rubycas']" />

          <condition property="cucumberBool">
               <equals arg1="${test_type}" arg2="cucumber" />
          </condition>

          <condition property="rspecBool">
               <equals arg1="${test_type}" arg2="rspec" />
           </condition>
       </target>

       <target name="rspec" if="rspecBool" depends="init">
           <exec executable="rspec" outputproperty="result">
               <arg value="--require teamcity/spec/runner/formatter/teamcity/formatter" />             <arg value="--format Spec::Runner::Formatter::TeamcityFormatter" />
           </exec>
           <echo message="${result}" />
       </target>

       <target name="cucumber" if="cucumberBool" depends="init">
           <exec executable="cucumber" outputproperty="result">
               <arg value="--format junit" />
               <arg value="--out results" />
               <arg value="features" />
           </exec>
           <echo message="${result}" />
       </target>
   </project>

此构建文件用于在TeamCity下构建RubyCAS项目,并运行需要验证的任务
项目是否稳定且功能齐全。

现在的问题是,我无法将RSpec的输出输入TeamCity以识别测试。

您可以使用ant的exec任务运行任意系统调用,在您的情况下可能是RSpec:

类似于



我不知道你的跟踪工具是否能用上,因为它实际上是在ant之外执行命令。

已经在这条轨道上了,我认为你的评论是正确的。我将寻找一个可以做我想做的事情的gem,并将其作为rake任务的一部分。更新了主题。你的意见真的很有帮助。