java环境变量测试未找到,运行Java集成测试时未设置环境变量

When running our Java integration tests for a basic GET service, our application code cannot retrieve environment variables. However when we run the application itself it can retrieve the variables without issue.

We are developing on a Mac (el captiain) with intellij as our IDE. We have exported the variables in our bash_profile (e.g. export ORACLE_URL="*************"). And we can echo the variable after setting and refreshing.

We are completely stumped as to why they work during a gradlew bootrun but not during a test run. Is the bash_profile the correct place to store local environment variables?

解决方案

Our current working solution to create environment variables for our junit tests is to run the command "launchctl setenv USERNAME mrSmith". We've added this to the .bash_profile to persist the variable between restarts.

However Chii's answer appears to be the more sensible path of action. We have not managed to get this solution working in our instance of Intellij.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值