मैं स्क्वाडॉक का उपयोग उस वर्ग को नकल करने के लिए कर रहा हूं जिसमें कुछ अधिभारित विधियां हैं लेकिन मुझे कुछ त्रुटियां मिल रही हैं।मॉकिंग अधिभारित विधि
उदाहरण के लिए:
val out = mock[PrintStream]
(out.print _).expects("cmd \r\n")
निम्न त्रुटि बढ़ा:
[error] [...]/src/test/scala/chili.scala:19: ambiguous reference to overloaded definition,
[error] both method print in class PrintStream of type (x$1: String)Unit
[error] and method print in class PrintStream of type (x$1: Array[Char])Unit
लेकिन अगर मैं इस्तेमाल करने की कोशिश:
[info] [...]/src/test/scala/chili.scala:19: Unable to resolve overloaded method print
[info] (out.print(_: String)).expects("cmd \r\n")
[info] ^
[error] [...]/src/test/scala/chili.scala:19: value expects is not a member of String => Unit
[error] (out.print(_: String)).expects("cmd \r\n")
:
(out.print(_: String)).expects("cmd \r\n")
मैं भी कोई त्रुटि मिलती है
क्या स्कैला में ऐसा करने का कोई तरीका है? शायद एक और पुस्तकालय का उपयोग कर?
अच्छा जवाब। धन्यवाद – simao