我目前正在关注TeamCity以及如何让我们的Ruby测试运行。使用命令行或Rake构建器时,我可以正常运行测试。我现在试图解决的问题有两个方面:
在我之前的一个工作中,我们还依靠TeamCity来运行我们的.NET测试。我们使用了Nant,我们有了跟踪测试期间运行的查询量以及这些查询的平均执行时间的方法。
我现在尝试使用我的Ruby项目做同样的事情。因此,我要解决的第一个逻辑步骤是,如何使用Ant运行 RSpec 或 Cucumber 测试? 我试着看看Ant本身并稍微掌握它,但我找到的所有例子都是jRuby,我们都不会使用它。我们依赖于RVM和普通的Ruby安装。
问题的第二部分是,如何跟踪运行的查询量及其执行时间?我猜测可能有一个宝石或某种全局变量跟踪。很想以某种方式将这些信息输出回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>
现在的问题是,我无法将RSpec的输出输入TeamCity来识别测试。
答案 0 :(得分:1)
您可以使用ant的exec任务来运行任意系统调用,在您的情况下可能是rspec:
https://ant.apache.org/manual/Tasks/exec.html
的内容
<target name="rspec">
<exec executable="rake">
<arg value="spec"/>
</exec>
</target>
我不知道你的跟踪内容是否适用于此,因为它实际上是在ant之外执行命令。