假设我有一个库,其中包含既有一个被弃用的函数,又有一个更优选的函数:
我想在ScalaTest中测试
object MyLib {
def preferredFunction() = ()
@deprecated("Use preferredFunction instead", "1.0") def deprecatedFunction() = ()
}
我想在ScalaTest中测试
preferredFunction
和deprecatedFunction
两个函数。class MyLibSpec extends FreeSpec with Matchers {
"preferred function" in {
MyLib.preferredFunction() should be(())
}
"deprecated function" in {
MyLib.deprecatedFunction() should be(())
}
}
然而,在 MyLib.deprecatedFunction()
报告了一个废弃警告。
如何避免此警告?