如何使用jar文件运行mvn黄瓜测试? [英] How to run mvn cucumber test using jar file?

查看:123
本文介绍了如何使用jar文件运行mvn黄瓜测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用maven和黄瓜创建了一个测试自动化框架.

I have created a test automation framework using maven and cucumber.

1)我想创建一个包含所有内容(所有项目文件)的jar文件

1) I want to create a jar file which includes everything (all project files)

2)然后,我想使用上面创建的jar从命令行运行测试,就像使用命令一样

2) Then I want to run a test from the command line using above created jar like using the command

(mvn clean test -Dcucumber.options='--tags @all')

我不想使用main方法或其他任何方法.

I don't want to use the main method or anything.

推荐答案

java -Dcucumber.options="--tags @all" -jar your-test-jar.jar

尝试一下.尽管我不确定为什么您不想使用main方法.如果不使用main方法,它将变得过于复杂.

Try this. Although I am not sure why you don't want to use the main method. If you don't use the main method it will just become too complicated.

更新:

编写一个main方法,并从中运行Cucumber main方法.参数是您将作为Cucumber命令行参数传递的参数.

Write a main method and run Cucumber main method from it. The arguments are what you would pass in as your Cucumber command line arguments.

public static void main(String[] args) throws Throwable {
    String[] arguments = {"a", "b"};
    cucumber.api.cli.Main.main(arguments);
}

如果我清楚地理解了您的问题,则可能可以完成您的工作.

If I have understood your question clearly, this might do your work.

这应该有助于您从可执行文件中运行Cucumber.

This should help you run Cucumber from your executable.

这篇关于如何使用jar文件运行mvn黄瓜测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆