Tôi chạy vào một vấn đề trong khi viết một khớp tùy chỉnh cho NodeSeq:ScalaTest - văn bản tùy chỉnh quẹt
private def matchXML(expected: NodeSeq) = new Matcher[NodeSeq] {
def apply(left: NodeSeq): MatchResult = MatchResult(left xml_== expected,
"XML structure was not the same (watch spaces in tag texts)",
"XML messages were equal")
}
này biên dịch, nhưng đoạn mã sau:
val expected : NodeSeq = ...
val xml : NodeSeq = ...
xml should matchXML(expected)
nguyên nhân:
error: overloaded method value should with alternatives:
(beWord: XMLStripDecoratorTests.this.BeWord)XMLStripDecoratorTests.this.ResultOfBeWordForAnyRef[scala.collection.GenSeq[scala.xml.Node]] <and>
(notWord: XMLStripDecoratorTests.this.NotWord)XMLStripDecoratorTests.this.ResultOfNotWordForAnyRef[scala.collection.GenSeq[scala.xml.Node]] <and>
(haveWord: XMLStripDecoratorTests.this.HaveWord)XMLStripDecoratorTests.this.ResultOfHaveWordForSeq[scala.xml.Node] <and>
(rightMatcher: org.scalatest.matchers.Matcher[scala.collection.GenSeq[scala.xml.Node]])Unit
cannot be applied to (org.scalatest.matchers.Matcher[scala.xml.NodeSeq])
xml should (matchXML(expected))
Bất kỳ ý tưởng nào có ý nghĩa gì?
định nghĩa của NodeSeq là gì? –
@ MikaëlMayer Tôi cho rằng 'scala.xml.NodeSeq' – gzm0