我目前正在做最高尚的编程工作,为Json编码/解码编写测试.我正在为Json使用
Argonaut.io,为我的测试框架使用
Scalatest.在scalatest下,在断言验证期间使用===会在发生故障时提供附加信息,而使用==只是给出了这个org.scalatest.exceptions.TestFailedException被抛出..但是,scala编译器不满意.这是代码:
val default = new broadcast("default","default","default") test("Should parse out network when present") { val hcursor = testHCursor(jsonPath + "complete-broadcast.json") val actualNetwork = Parser.broadcastDecodeJson(hcursor) .getor(default) .network assert(actualNetwork === "ESPNU") }
这喷出了这个:
[info] Compiling 1 Scala source to /home/vagrant/waltercamp/waltercamp-dataservice/target/scala-2.10/test-classes... [error] /home/vagrant/waltercamp/waltercamp-dataservice/src/test/scala/io/ptx/waltercamp/schedules/broadcastParserSuite.scala:16: type mismatch; [error] found : actualNetwork.type (with underlying type String) [error] required: ?{def ===(x$1: ? >: String("ESPNU")): ?} [error] Note that implicit conversions are not applicable because they are ambiguous: [error] both method ToEqualOps in trait ToEqualOps of type [F](v: F)(implicit F0: scalaz.Equal[F])scalaz.Syntax.EqualOps[F] [error] and method convertToEqualizer in trait Assertions of type (left: Any)broadcastParserSuite.this.Equalizer [error] are possible conversion functions from actualNetwork.type to ?{def ===(x$1: ? >: String("ESPNU")): ?} [error] assert(actualNetwork === "ESPNU") [error] ^ [error] one error found [error] (test:compile) Compilation Failed
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。