Search code examples
javacucumberbddweb-api-testing

Cannot get api hostname via System property in Java


Recently got the code to write bdd tests with cucumber on Java. There is already maven project with couple of tests and test framework. I need to continue writing bdd tests using this framework. I am writing API tests and try to run them and i get the error. I found where it fails to run further but I want to figure out what's the idea of doing so in the code. Let me share some code:

So the test framework is collecting info about the API host name this way:

public class AnyClass {

   private static final String API_HOSTNAME = "hostname";

   private static String getAPIHostName() {
      String apiHostName = System.getProperty(API_HOSTNAME);

...

}

When i leave it as is, and run the test, i get the error that host name is empty.

Can you advise on what might be expected to have under System property key "hostname"?

p.s. I tried to use http://localhost and http://127.0.0.1, where my api is located instead of assigning system property but it cannot find such host name.


Solution

  • Can you advise on what might be expected to have under System property key "hostname"?

    Yes, I needed to run tests in command line with the syntax like: mvn clean verify -Dhostname=http://127.0.0.1:8080