LoginSignup
0
1

More than 3 years have passed since last update.

Javaのテストで環境変数がいるとき

Posted at

やりたいこと

環境変数で値を上げてるところも含めてテストしたいときに、テスト時に環境変数がなくて死ぬのをなんとかしたい

解決策

pomに書く

pom.xml
                        <plugin>
                                <artifactId>maven-surefire-plugin</artifactId>
                                <version>{your version}</version>
+                               <configuration>
+                               <environmentVariables>
+                                       <TEST_ENV>100</TEST_ENV>
+                               </environmentVariables>
+                               </configuration>
                        </plugin>

これでコード内でSystem.getenv("TEST_ENV")としてるところで100がとれるようになる

参照

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1