Mocking and Test Fixtures
Use traits and test fixtures to mock behavior for unit testing.
Fixture Example
trait Database {
  def getUser(id: Int): String
}
class MockDatabase extends Database {
  def getUser(id: Int): String = "TestUser"
}Use the mock in your tests to simulate behavior without real dependencies.
class ServiceTest extends AnyFunSuite {
  val db = new MockDatabase()
  test("getUser returns test user") {
    assert(db.getUser(1) == "TestUser")
  }
}