Alexander Herrera Alexander Herrera - 2 years ago 87
Java Question

send parameters from test suite to test case in junit 4

I've got four junit cases and I need to pass them a parameter, that is the same for all of them, but this parameter is created in a dynamic way in the test suite. How can I pass a parameter from the test suite to all the tests in the test case?

Answer Source

If its just a string parameter, you can set the System Property and access it in test cases.

If you want to programmatically do it, you can do it at one place System.setProperty("x","123"); otherwise you can always pass System properties from command line as -Dx=123.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download