Set System Property for JUnit Runner (Eclipse) to test a Spring Web App

后端 未结 3 1689
情深已故
情深已故 2021-02-07 02:26

Our web app uses SystemPropertyPlaceholder to load property files depending on the value of a system property (see below)

The default setup for running it locally is sto

相关标签:
3条回答
  • 2021-02-07 02:56

    You could try to use depends-on attribute to have method invoking bean run before others

    0 讨论(0)
  • 2021-02-07 03:15

    I am working on exactly the same problem now and hopefully found the way. You can call System.setProperty() into the static initializer of your test case.

    0 讨论(0)
  • 2021-02-07 03:16

    In Eclipse, right-click the JUnit test class, select Run As > Run Configurations..., then go to Arguments tab, and under VM Arguments, add in the system property entry, e.g. -Dcatalina.base=C:\programs\apache-tomcat-7.0.32

    0 讨论(0)
提交回复
热议问题