title: How to access main method variables from scalatest-scala
body: <p>I am couple of days into scala programming</p>
  
  <p>I was playing with the scala code here</p>
  
  <pre><code>import org.apache.spark.SparkContext
  import org.apache.spark.SparkContext._
  import org.apache.spark.SparkConf
  
      object SimpleApp {
        def main(args:Array[String]) {
          val logFile = "../samplelog.txt"
          val conf = new SparkConf().setAppName("Simple Application")
          val sc = new SparkContext(conf)
          val logData = sc.textFile(logFile, 2).cache()
          val numAs = logData.filter(line =&gt; line.contains("a")).count()
          val numBs = logData.filter(line =&gt; line.contains("b")).count()
  
          def getNumAs : Long = numAs
          def getNumBs : Long = numBs
  
          println("Lines with a: %s, Lines with b: %s".format(numAs, numBs))
        }
      }
  </code></pre>
  
  <p>My scalatest is as follows</p>
  
  <pre><code>import org.scalatest._
  
      class simpleAppTest extends FunSuite with Matchers {
  
      test ("number of a's and b's")
  
      val acount=SimpleApp.numAs
      val bcount=SimpleApp.numBs
  
      acount should be(2)
      bcount should be(1)
  
  
      }
  </code></pre>
  
  <p>The issue is that I am unable to get values of getnumAs and getnumBs. The compiler complains that getnumAs/getnumBs is not a value of unit. I tried looking for scaladocs or sample code but have no clue on how to resolve this.</p>
  
  <p>kindly help</p>
  
  <p>thanks</p>