0

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.

Paulus
  • 138
  • 1
  • 11
  • It seems your framework was designed to have the host that should be tested passed as a system property on the command line. What is the problem with that? – RealSkeptic Feb 13 '17 at 15:31
  • @RealSkeptic, yes, this is my assumption too. But it is strange, that you can't build the maven project without this parameter. Should i insert it somewhere in pom file to make it work? – Paulus Feb 13 '17 at 17:39
  • The problem is, that even though i set String apiHostName = "http://locahost", it says ClientHttpProtocolError, moreover i need to provide port and folder where api requests should go to. Unfortunately there is no instruction on how to run existing tests, providing inputs in command line and i got stuck. – Paulus Feb 14 '17 at 07:21
  • If the question is "what data should I provide?" then your guess is as good as ours, and probably better. As far as I can determine, you've presented nothing pertinent to the data's *usage*, much less its meaning. Even the details of the error you're seeing might be useful. You could consider proceeding by stepping through the test in question in a debugger, to get a better idea of what it's trying to do. – John Bollinger Feb 14 '17 at 13:01

1 Answers1

0

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

Paulus
  • 138
  • 1
  • 11