title: Unit Testing and Mac OS X 10.10.3 Language and Region Settings
body: <p><strong>THE CASE</strong></p>
  
  <p>Without going much into details, <code>mvn test</code> fails on system with French language settings. In order to target that issue with regression testing, I want to create a regression test, which sets locale to French, and the runs unit tests with <code>Maven</code>.</p>
  
  <p>I switch between English and French in <code>System Preferences &gt; Language &amp; Region &gt; Advanced &gt; Format language</code>.</p>
  
  <p><strong>THE PROBLEM</strong></p>
  
  <ol>
  <li>While on English locale, I check the settings with <code>locale</code>:</li>
  </ol>
  
  <blockquote>
  <pre><code>LANG="en_GB.UTF-8"
  LC_COLLATE="en_GB.UTF-8"
  LC_CTYPE="en_GB.UTF-8"
  LC_MESSAGES="en_GB.UTF-8"
  LC_MONETARY="en_GB.UTF-8"
  LC_NUMERIC="en_GB.UTF-8"
  LC_TIME="en_GB.UTF-8"
  LC_ALL=
  </code></pre>
  </blockquote>
  
  <ol start="2">
  <li><p>Run <code>mvn test</code>, it passes</p></li>
  <li><p>Switch to French locale with OS X GUI</p></li>
  <li><p>Run <code>mvn test</code>, it fails (as expected)</p></li>
  <li><p>Run <code>locale</code> in the same terminal - it still produces the same results as before (although it shouldn't, as I switched to French)</p></li>
  <li><p>Open new terminal and run <code>locale</code>:</p></li>
  </ol>
  
  <blockquote>
  <pre><code>LANG=
  LC_COLLATE="C"
  LC_CTYPE="UTF-8"
  LC_MESSAGES="C"
  LC_MONETARY="C"
  LC_NUMERIC="C"
  LC_TIME="C"
  LC_ALL=
  </code></pre>
  </blockquote>
  
  <p><strong>THE FINDINGS</strong></p>
  
  <p>For some reason, output of <code>locale</code> command corresponds to locale settings as of the time when the terminal was started. If you open up terminal, change locale via GUI and then run <code>locale</code> command, which won't be visible to this command.</p>
  
  <p>Subsequently, if I amend locale by exporting <code>LC_ALL</code> or other variables of that kind, this does not actually change unit test results. If I change locale via GUI, it will.</p>
  
  <p><strong>THE QUESTION</strong></p>
  
  <p>How to change locale using command line, so that they are actually applied?</p>