Giter Club home page Giter Club logo

Comments (9)

akka-ci avatar akka-ci commented on May 18, 2024

Comment by ktoso
Saturday Apr 30, 2016 at 00:21 GMT


It's an interesting idea, and we might consider pull requests if you'd like to contribute it as a feature.
In the team we won't be able to focus on this for now - there's more urgent fish to fry.

from akka-http.

chetanmeh avatar chetanmeh commented on May 18, 2024

This would be a useful feature to have and would enable running a similar test suite against a remote server to perform integration testing.

from akka-http.

raboof avatar raboof commented on May 18, 2024

Actually I think this might be covered by the ~!> feature introduced in #3014 and available on version 10.2.0-M1, https://doc.akka.io//docs/akka-http/snapshot/routing-dsl/testkit.html#integration-testing-routes

Closing this issue with that reference - feel free to reopen when you think this is not quite covered yet.

from akka-http.

chetanmeh avatar chetanmeh commented on May 18, 2024

~!> indeed looks the right one. Only thing not sure if it can be used to run against a pre existing running server instead of always starting a new one. Would give it a try

from akka-http.

raboof avatar raboof commented on May 18, 2024

Only thing not sure if it can be used to run against a pre existing running server instead of always starting a new one

~!> will start a server for you. If you want to test against a preexisting running server I'd use a regular Http().singleRequest call. I don't think you can use the ~> check notation then, though - but that might not make sense anyway, since that exposes things (rejections etc) that aren't visible over the network anyway.

from akka-http.

chetanmeh avatar chetanmeh commented on May 18, 2024

Ack. So here is I want to do. I have a existing test suite which checks my API implementation. For example below snippet just check if the server responds with same message json

    val msg = readJson[Message]("message.json")
    val msgEntity = Marshal(msg).to[MessageEntity].futureValue
    val request = Post("/message").withEntity(msgEntity)
    
    request ~> api.routes ~> check {
      responseAs[Message] shouldBe msg
    }

Now I would also like to leverage the same test suite against an existing running server say a server instance running in stage environment. Currently to perform integration testing I would need to implement logic similar to above but using Http().singleRequest. However if I can leverage the same code to do both kind of test it would be greatly help!

I see that some semantics like rejections cannot be preserved. But if the test mostly relies on actual response like status and response headers etc then it should mostly work transparently.

from akka-http.

chetanmeh avatar chetanmeh commented on May 18, 2024

Also sorry for the noise with similar discussion on #3014. We can keep the discussion here (or there) as you prefer

from akka-http.

raboof avatar raboof commented on May 18, 2024

I think the easiest way to do that might be to pass in a HttpRequest => Future[HttpResponse] that is implemented either with api.routes or with a call to the integration tests service, and then do your assertions on the HttpResponse. On Akka HTTP 10.2.0 there is an implicit conversion available from Route to HttpRequest => Future[HttpResponse] so that is fairly easy to do.

I don't see an easy way to make the test usable both 'in-process' and calling an external service using the testkit ~> tools (though I see how it'd be neat).

from akka-http.

chetanmeh avatar chetanmeh commented on May 18, 2024

Thanks @raboof for the pointers. Would look into them. Though having them done with benefit of Tesk kit DSL would be very neat

from akka-http.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.