使用Specs2测试json数据

 王小小小小弦 发布于 2023-02-11 15:18

我添加了(在built.sbt中)matcher-extra: -

 "org.specs2"              %% "specs2"            % "2.3.4"                  % "test",
"org.specs2"               % "specs2-matcher-extra_2.10" % "2.3-scalaz-7.1.0-M3",

("/"符号未解析)

我对Json的示例测试用例如下所示: -

package specs.model
import org.specs2.mutable.Specification
import org.specs2.matcher.JsonMatchers

class Json extends Specification with JsonMatchers {

"Json Matcher" should {
"1st field" in {
  val json = """{"name":"sagar"}"""
  json must  /("name" -> "sagar")
}
"2nd field" in {
  val json = """{"id":1}"""
  json must  /("id" -> 1.0)
}
}
}

ERRORMSG: -

 [info] Compiling 2 Scala sources to \target\scala-   2.10\test-classes...
 [info] Json
 [info] 
 [info] Json Matcher should
 [info] + 1st field
 [info] + 2nd field
 [info] 
 [info] Total for specification Json
 [info] Finished in 76 ms
 [info] 2 examples, 0 failure, 0 error
 [trace] Stack trace suppressed: run 'last specBuilder/test:test' for the full output.
 [error] Could not run test specs.model.Json: java.lang.NoSuchMethodError:     scalaz.Scalaz$.tuple2Monoid(Lscalaz/Monoid;Lscalaz/Monoid;)Lscalaz/std/Tuple2Monoid;
 [error] Error: Total 0, Failed 0, Errors 0, Passed 0, Skipped 0
 [error] Error during tests:
 [error]    specs.model.Json
 [error] (specBuilder/test:test) sbt.TestsFailedException: Tests unsuccessful
 [error] Total time: 9 s, completed 11 Dec, 2013 5:12:39 PM

我在这里打击,请给我解决方案

谢谢,

GSY

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有