0

I have application.property file in project

username=stm-bce93d@nurego.com
password=123456
baseId=4e1c-a459-0885d5849686
serviceId=49ca-a348-38ef3dc89a16

and when I run my test I want to change only password field and get it from system variable. how can I change it?

Hayami Pysh
  • 285
  • 1
  • 5
  • 14
  • https://stackoverflow.com/questions/46736711/update-the-application-property-in-java – juju Apr 29 '20 at 07:44
  • maybe you can see this; [change property at runtime](https://stackoverflow.com/q/37052857/8311273) – 董诚怡 Apr 29 '20 at 07:47
  • 1
    If you're using `@SpringBootTest`, there's an annotation parameter to supply properties. (Note that you shouldn't be putting credentials into your source code anyway; use environment variables at runtime or a more comprehensive "secrets" solution like Vault or your deployment environment's management tools.) – chrylis -cautiouslyoptimistic- Apr 29 '20 at 07:54

1 Answers1

1

One option is to use profiles. Enabling the test profile you can define a different value in application-test.properties, which would look something like that

username=stm-bce93d@nurego.com
password=${PWD}
baseId=4e1c-a459-0885d5849686
serviceId=49ca-a348-38ef3dc89a16

PWD is an environment variable

Beppe C
  • 11,256
  • 2
  • 19
  • 41