首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >===状态传递任何状态。

===状态传递任何状态。
EN

Stack Overflow用户
提问于 2015-03-16 16:35:05
回答 1查看 256关注 0票数 1

我在喷雾测试试剂盒中进行了最有规模的测试,我不明白为什么每次测试都通过,尽管实际情况如此。

代码语言:javascript
复制
import akka.actor._
import akka.event.LoggingReceive
import akka.testkit.TestProbe
import com.ss.rg.service.ad.AdImporterServiceActor.{GetImportStatus, StatusOfImport}
import org.scalatest.{MustMatchers, WordSpecLike}
import spray.http._
import spray.testkit.ScalatestRouteTest


class AdServiceApiTest extends WordSpecLike with MustMatchers with ScalatestRouteTest {

  "AdService REST api " must {
    "POST for import with mandatory parameters should be processed" in {
      val p = TestProbe()
      val addressServiceMock = system.actorOf(Props(classOf[AdServiceActorMock], p.ref))

      Post("/service/ad/import?adId=1") ~> new AdServiceApi(addressServiceMock).route ~> check {
        handled must be(true)

//        rejections must have size 1
        response.status === StatusCodes.NotAcceptable
      }
    }
  }

测试通过,即使状态应该是不同的,当我使测试失败的明显原因,如拒绝.错误消息如下:

代码语言:javascript
复制
Request was not rejected, response was HttpResponse(202 Accepted,HttpEntity(text/plain; charset=UTF-8,The request has been accepted for processing, but the processing has not been completed.),List(),HTTP/1.1)
org.scalatest.exceptions.TestFailedException: Request was not rejected, response was HttpResponse(202 Accepted,HttpEntity(text/plain; charset=UTF-8,The request has been accepted for processing, but the processing has not been completed.),List(),HTTP/1.1)
    at spray.testkit.ScalatestInterface$class.failTest(ScalatestInterface.scala:25)

似乎我错过了一些重要的概念。

有人能澄清一下吗?

更新:下列操作正确

代码语言:javascript
复制
status must equal(StatusCodes.Accepted)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-03-16 18:06:14

===是不够的。你得写

代码语言:javascript
复制
status should === (StatusCodes.NotAcceptable)

代码语言:javascript
复制
assert(status === StatusCodes.NotAcceptable)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29082171

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档