title: How to run a Spark test from IntelliJ (or other IDE)
body: <p>I am trying to create a Test for some Spark code. The following code fails when getting a SparkSession object. NOTE: The test runs fine when running from the cli: gradle my_module:build</p>
  
  <pre><code>@Test
  def myTest(): Unit = {
    val spark = SparkSession.builder().master("local[2]").getOrCreate()
    ...
  }
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>java.lang.IllegalArgumentException: Can't get Kerberos realm
  ...
  Caused by: java.lang.reflect.InvocationTargetException
  ...
  Caused by: KrbException: Cannot locate default realm
  </code></pre>
  
  <p>My set-up: IntelliJ + Gradle + Mac OS</p>
  
  <p>Questions:</p>
  
  <ul>
  <li>How do I run a Spark Test from within IntelliJ?</li>
  <li>Why is Spark looking for Kerberos at all when running 'local'</li>
  </ul>