将参数从 Eclipse 传递到 TestNG

发布于 2024-11-02 12:48:22 字数 188 浏览 4 评论 0原文

我正在寻找一种在 TestNG 中执行测试方法的方法,这样当我单击 Eclipse 中的某个文件并执行 Run -> 时, TestNG,它将传递所选文件的全名,并且测试接收相同的文件名作为参数。

这可能与 TestNG 有关吗?我知道如何让 Eclipse 发送正确的参数,我不只是确定如何让 TestNG 接受它。

谢谢

I am looking for a way to do a test method in TestNG such that when I click in a certain file in Eclipse and make Run -> TestNG, it will pass that selected file's full name and the test receives that same file name as argument.

Is this possible to do with TestNG? I know how to make Eclipse send the correct argument, I am not just sure how to make TestNG accept it.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只涨不跌 2024-11-09 12:48:22

这有点 hacky...但您可以尝试从 Ant 实例化它。无需编写 build.xml,只需直接调用 testNG 任务 并为其提供类/文件名。这样所有的工作就为你完成了。我还相信 TestNG 在运行时需要它自己的 JVM,所以这也可以解决这个问题。

编辑:我想我误解了你的问题。

This is kind of hacky... but you could try instantiating it from Ant. Rather than write a build.xml just call the testNG task directly and feed it the class/file name. That way all the work is done for you. Also I believe that TestNG requires it's own JVM when it's running, so this will take care of that as well.

Edit: I think I misread your question.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文