Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
测试响应是一个JsonArray——Play框架2.4.2规范2测试_Json_Scala_Playframework_Spec2 - Fatal编程技术网

测试响应是一个JsonArray——Play框架2.4.2规范2测试

测试响应是一个JsonArray——Play框架2.4.2规范2测试,json,scala,playframework,spec2,Json,Scala,Playframework,Spec2,我试着用剧本2.4.2,规范2来测试贝娄 " test response Returns a json Array" in new WithApplication { val response = route(FakeRequest(GET, "/myservice/xx")).get // ??? test response is a json array } 测试此场景的方法是什么?这里有一种可能性 控制器 @Singleton class BarryControll

我试着用剧本2.4.2,规范2来测试贝娄

" test response Returns a json  Array" in new WithApplication {
  val response = route(FakeRequest(GET, "/myservice/xx")).get

  // ??? test response is a json array
}
测试此场景的方法是什么?

这里有一种可能性

控制器

  @Singleton 
  class BarryController extends Controller{
     def barry = Action { implicit request =>

     val json: JsValue = Json.parse("""
      {
       "residents" : [ {
         "name" : "Fiver",
         "age" : 4,
         "role" : null
       }, {
        "name" : "Bigwig",
        "age" : 6,
        "role" : "Owsla"
      } ]
        }
         """)
  Ok(json)
  }
}
试验

希望这能给你一些关于你可以测试什么或者你想做什么的想法。

这里有一个可能性

控制器

  @Singleton 
  class BarryController extends Controller{
     def barry = Action { implicit request =>

     val json: JsValue = Json.parse("""
      {
       "residents" : [ {
         "name" : "Fiver",
         "age" : 4,
         "role" : null
       }, {
        "name" : "Bigwig",
        "age" : 6,
        "role" : "Owsla"
      } ]
        }
         """)
  Ok(json)
  }
}
试验

希望这能给你一些关于你可以测试什么或者你想做什么的想法。

这里有一个可能性

控制器

  @Singleton 
  class BarryController extends Controller{
     def barry = Action { implicit request =>

     val json: JsValue = Json.parse("""
      {
       "residents" : [ {
         "name" : "Fiver",
         "age" : 4,
         "role" : null
       }, {
        "name" : "Bigwig",
        "age" : 6,
        "role" : "Owsla"
      } ]
        }
         """)
  Ok(json)
  }
}
试验

希望这能给你一些关于你可以测试什么或者你想做什么的想法。

这里有一个可能性

控制器

  @Singleton 
  class BarryController extends Controller{
     def barry = Action { implicit request =>

     val json: JsValue = Json.parse("""
      {
       "residents" : [ {
         "name" : "Fiver",
         "age" : 4,
         "role" : null
       }, {
        "name" : "Bigwig",
        "age" : 6,
        "role" : "Owsla"
      } ]
        }
         """)
  Ok(json)
  }
}
试验


希望这能为您提供一些关于您可以测试什么或您可能想要做什么的想法。

哪个版本的play2play framework 2.4.2哪个版本的play2play framework 2.4.2哪个版本的play2play framework 2.4.2哪个版本的play2play framework 2.4.2