Mock spark Dataframewriter for unit testing

Viewed 94

I am writing unit testcase for a function using mockito that writes the df to a hivetable using insertinto.

def method():Unit={
val df=spark.sql("some query") 
df.write.insertInto("tablename")
}

How can I mock this part of the function (within a scala object) to do nothing or skip this call. I do not want to write it to any external source system hence mocking.

0 Answers
Related