Unit testing EssentialAction
See original GitHub issueWhen we are trying to test an essential action the status is always 500
val a = EssentialAction { request =>
Action { Ok("") }(request)
}
Helpers.await(a(FakeRequest()).run).header.status must be equalTo OK
Is it a bug?
Issue Analytics
- State:
- Created 10 years ago
- Comments:17 (15 by maintainers)
Top Results From Across the Web
Play 2.1: unit testing EssentialActions - Stack Overflow
An essential action is a RequestHeader => Iteratee[Indata, Result] , you can apply it to FakeRequest since it implements RequestHeader .
Read more >Testing your application with ScalaTest - Play Framework
Unit Testing EssentialAction. Testing Action or Filter can require testing an EssentialAction (more information about what an EssentialAction is). For this, ...
Read more >Play 2.5 Unit testing controller failed with ScalaTestPlus
In my controller unit test, I got something like above before. However when I upgrade to Play 2.5, I got some error: could...
Read more >enlarge your test scope - Blog
A traditional approach of unit test is to consider one class or function of one ... String), EssentialAction] , making really easy to...
Read more >Action Officer Skills For Your Resume And Career - Zippia
... coding comments, unit testing, integration testing, design documents, ... 15 Essential Action Officer Skills For Your Resume And Career ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sorry, I do not want to be rude, but I am not happy with the answer.
The question was about unit testing, and starting a FakeApplication is not an optimal way to unit test. FakeApplication is intended to be used in functional tests: http://www.playframework.com/documentation/2.2.x/ScalaTest
On my opinion, starting a FakeApplication for an unit test is not a viable solution because:
And I do not really understand why a such difference between Action and EssentialAction.
For example, it is very easy to unit test an Action, even if it consumes a body:
(scala test)
By simply changing the type of the Action, it is much more complicated:
On my opinion:
That would help this framework to be even more awesome for testing.
@jroper PR: https://github.com/playframework/playframework/pull/2086
Feedback welcome.