如何在 Java 中为 Fitnesse Fixture 传递程序参数?

发布于 2024-12-29 16:07:16 字数 398 浏览 1 评论 0原文

我有一个装置需要将一些系统参数传递给它。我该如何做同样的事情。 即 java MyClass -Darg1=x -Darg2=y

如何将 -Darg 值传递到我的测试中。

@担。我的坏处是我提到了命令行参数。我真正想做的是传递系统属性,正如您所指出的。我有一些设置,例如区域(NA/EMEA 等)、环境(SIT/UAT)等,基于这些设置各种 url 等不同。我必须在 Fitnesse 中编写测试,其中我从决策表中传递测试屏幕的值。但我希望能够指示这些测试应该在某某区域/环境组合上运行。目前我有一个 junit 测试触发 Selenium 播放,我可以通过传递 -Dregion 等来控制它从 IDE/Maven 的调用。通过 Fitnesse,我想知道如何传递这些系统参数,以便我的 Fixture 在被调用时可以访问这些属性并触发播放硒相应。

I have a fixture that needs some System arguments to be passed into it.How can i do the same.
ie java MyClass -Darg1=x -Darg2=y

how do i pass the -Darg values into my test.

@Dan. My Bad that I mentioned command line arguments.What I really intend to do is pass System properties as you pointed out.I have some settings like Region(NA/EMEA etc),Environment(SIT/UAT) etc based on which various urls etc differ.I have to compose tests in Fitnesse where I pass the values for the test screen from my decision table.But I want to be in a position to dictate that these tests should be run on so and so region/env combination.AT present I have a junit Test that triggers Selenium playback and I have control over its invocation from IDE/Maven by passing -Dregion etc.With Fitnesse I want to know how to pass these System arguments so that my Fixture when it gets invoked has access to these properties and it triggers playback of Selenium accordingly.

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

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

发布评论

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

评论(1

荭秂 2025-01-05 16:07:16

要将变量传递到 FitNesse,您可以设置环境变量。例如,从命令行启动 FitNesse,如下所示:

set SUT=www.google.de
java -jar fitnesse.jar -p 8080

您可以像其他变量一样在 FitNesse 中使用环境变量 - FitNesse 测试表中的“${SUT}”将替换为上例中的 www.google.de。

然后,要将 SUT 的值放入测试装置中,您可以在测试装置中添加一个静态类,如下所示:

public class Environment {
    public static string SUT;
}

在 FitNesse 设置代码中的某处设置环境 SUT 变量:

!|script|Environment|
|SUT|${SUT}|

然后,Environment.SUT 在整个装置代码中可用。


更新:

另请参阅 Dan 关于如何通过使用 -D 参数启动 fitNesse 来使用 Java 系统变量的评论。

To pass variables into FitNesse, you can set an environment variable. For example, start FitNesse from the command line like this:

set SUT=www.google.de
java -jar fitnesse.jar -p 8080

You can use environment variables in FitNesse like other variables - '${SUT}' in a FitNesse test table will be replaced with www.google.de in the above example.

Then to get the value of SUT into the test fixture, you can add a static class in the test fixture like this:

public class Environment {
    public static string SUT;
}

And somewhere in your FitNesse Setup code set the Environment SUT variable:

!|script|Environment|
|SUT|${SUT}|

Environment.SUT is then available throughout your Fixture code.


Update:

Also see Dan's comment on how use Java System variables by starting fitNesse with the -D parameter.

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