0

A test should run:

  • locally against local installation
  • locally against the server installation

Of course, the test must use different host URLs for those runs. How can I set them from outside of the code of the test? I thought about something as tying different test groups to different parameters values, but any way will be good.

Gangnus
  • 24,044
  • 16
  • 90
  • 149
  • two ideas. How about https://stackoverflow.com/a/13074108/4506285 (test with theories) or Is parameterized test what you are looking for? Check this link http://www.tutorialspoint.com/junit/junit_parameterized_test.htm – pwain Nov 27 '17 at 20:50
  • @pwain If ever my managers will make me to use JUnit and I won't be able to struggle, I will use your first reference. Interesting tricks. But better it will be to use the normal testing system - look at my answer. – Gangnus Nov 27 '17 at 23:50

1 Answers1

0

The parameters in TestNG cannot be tied to groups. Because of that mistake I couldn't find the answer. They can be tied to tests or suits though, so, everything is OK.

<suite name="My suite">
  <parameter name="first-name"  value="Cedric"/>
  <test name="Simple example">
............
@Parameters({ "first-name" })
@Test
public void testSingleString(String firstName) {
  System.out.println("Invoked testString " + firstName);
  assert "Cedric".equals(firstName);
}

The example is from the documentation.

So, we can set the value of a parameter from outside of the test code. Btw, tricks from @pwain fist reference can be useful in some situations, too, especially if we use JUnit instead of TestNG

Gangnus
  • 24,044
  • 16
  • 90
  • 149