Comments (9)
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.
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.
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.
~!>
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.
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.
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.
Also sorry for the noise with similar discussion on #3014. We can keep the discussion here (or there) as you prefer
from akka-http.
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.
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)
- Internal server error triggered by “Accept-Charset” header with unexpected value HOT 4
- Not possible to load project in IntelliJ 2023.2.1 HOT 1
- Duplicated 100 responses if there is an exception thrown by the unmarshaller HOT 1
- Several HTTP/2 client settings are never used anywhere
- failed: RouteDirectivesSpec -> should allow easy handling of futured ToResponseMarshallers
- Cannot Unmarshall Seq[String] Outside HOT 1
- Release 10.6.0-M1
- Release 10.6.0-M2
- CVE-2023-44487 HOT 3
- Release 10.5.3
- Release 10.6.0
- Failed: Http2ClientSpec should send RST_STREAM if entity stream is canceled HOT 2
- Failed: Http2ServerSpec send RST_STREAM if entity stream is canceled
- Remove dependency on `sbt-dependency-graph` HOT 1
- Release 10.6.1
- Failed: Native image tests HOT 1
- SSE (and maybe more) marshalling/unmarshalling require classic system HOT 1
- fail: CI is failing to publish docs HOT 2
- The akka.http.cors package is not exist HOT 1
- Release 10.6.2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from akka-http.