0

I'm building a test suite with Cucumber on Java + Maven + jUnit and I need to pass a username and a password to the test suite so it can log in to the application under test.

I don't like the idea of hardcoding the credentials, so I thought maybe I should be passing them as arguments when running the maven command, or maybe I can add them in the pom.xml somewhere and then read them in the code. But I don't know how to do either. Or maybe there's a third option that I haven't thought of...

1

You can do Data-driven testing using these,

  1. Scenario Outline with Examples keyword

  2. Using external Files: Excel, Json, XML

For more details check below links:
1. Data-driven-framework-with-excel
2. Adding_source_to_gherkin_script

1

you can read the topic about enums and interfaces in Java. Maybe it will help you to create something as you want. There are a lot of decisions. The xml file can be created with different accounts as well then you pass it through your Interfaces, Classes and etc.

<users>
    <user>
        <lastname>John</lastname>
        <firstname>Doe</firstname>
        <code>LOGIN</code>
        <password>PASSWORD</password>
    </user>
1

There is a feature called Scenario Outline for data driven tests in cucumber.

It can be used in this scenario to pass different user/passwords as data to the test as parameters.

enter image description here

  • 2
    Could you please add more details about Scenario Outline, How it helps to resolve the same. – Bharat Mane Feb 19 '18 at 12:36
  • Bharat, please read on Scenario outline feature and come back if you have any specific questions. – Vishal Aggarwal Feb 19 '18 at 12:53
  • 2
    Please read sqa.stackexchange.com/help/how-to-answer for more information on what constitutes a good answer. A single sentence mentioning the cucumber feature Scenario Outline does not constitute a good answer at this site. – Kate Paulk Feb 19 '18 at 16:16
0

I've found that keychain and secret stash can help with these - plugins that can access your operating system's credential storage.

The documentation should give you more information, but essentially, you store your passwords in your OS's password manager, and then call the plugin's library to get the passwords like an api.

  • Please expand on your answer to explain how it solves the OP's problem. – Kate Paulk Feb 20 '18 at 12:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.