I was working with Scala Spark applications recently. Because I didn’t know much about mocking table reads in Spark and had to write a unit test for a function, I removed all the spark.read calls from the function. When I looked at the function to be tested, I noticed that it had become less cohesive.