我正在尝试为 behat 测试设置一个 ant 构建脚本,以便我可以从 jenkins 运行它们。当我使用 bin/behat 或 ./bin/behat 从命令行运行 behat 时,输出按预期工作。但是当我使用下面的 ant 脚本时
<project name="behat" basedir=".">
<exec dir="bin" executable="./behat">
</exec>
</project>
我收到这个错误:
Buildfile: <mydir>/build.xml
[exec]
[exec]
[exec]
[exec] [RuntimeException]
[exec] Context class not found.
[exec] Maybe you have provided wrong or no `bootstrap` path in your behat.yml:
[exec] http://docs.behat.org/guides/7.config.html#paths
[exec]
[exec]
[exec]
[exec] behat [--init] [-f|--format="..."] [--out="..."] [--lang="..."] [--[no-]ansi] [--[no-]time] [--[no-]paths] [--[no-]snippets] [--[no-]snippets-paths] [--[no-]multiline] [--[no-]expand] [--story-syntax] [-d|--definitions="..."] [--name="..."] [--tags="..."] [--cache="..."] [--strict] [--dry-run] [--rerun="..."] [--append-snippets] [--append-to="..."] [features]
[exec]
[exec]
[exec] Result: 1
BUILD SUCCESSFUL
Total time: 0 seconds
最佳答案
您不应该从 bin 目录运行 behat。它不会找到您的 behat.yml 文件。
你应该像这样运行它:
./bin/behat
或者传递配置文件的路径:
cd bin
./bin/behat --config ../behat.yml
我没试过后者。您的 ant 脚本可能类似于:
<project name="behat" basedir=".">
<exec dir="${basedir}" executable="./bin/behat" />
</project>
关于linux - 用于 behat 错误的 ant 构建脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15530644/