简体   繁体   中英

how do i pass program arguments in java for my 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM