Our unit tests are usually written with JUnit, and our acceptance
tests are usually written with FitNesse. One of the 'light bulb'
moments we had a few years back is that unit tests and acceptance
tests that test the same code are not duplication. They have different
purposes and different scopes, with different levels of abstraction.
Making our FitNesse Fixtures instantiate a new Controller class or
find the Controller bean in the Spring Context is considered (to us)
an anti-pattern because it is going too deep and produces false
green-bar (this symptom may have been magnified because of the
flow-based nature of our application).
A better approach is to make the FitNesse Fixture produce a
MockHttpServletRequest and pass it to the correct URL with the
intended HttpMethod.
Sorry this explanation is implementation specific, but I hope I
understood your question enough to make a useful delineation. If I'm
way off please let me know.
Tim Andersen
> --
> You received this message because you are subscribed to the Google Groups
> "Specification by Example" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/specificationbyexample/-/yulJdClIK7EJ.
> To post to this group, send email to
> specificati...@googlegroups.com.
> To unsubscribe from this group, send email to
> specificationbyex...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/specificationbyexample?hl=en.
>
In practice, testing from the mockHttp layer without starting the
container has been a good technique for us. We haven't had difficulty
with test maintenance or being too implementation specific. When a URL
changes, there's one place to change it in test code. When we refactor
a controller, the mockHttp request often doesn't need to change
(because it doesn't care about implementation). When request
parameters change, then we need to also add them in the fixture that
creates the mockHttp request, but that is a contract change. As far as
the user authentication piece, you can add that to your mockHttp
request and assume it as part of the persona generating those
requests.
Please try it. For us, we have had to experiment with many different
levels of abstraction before we found the "sweet spot".
Regards,
Tim Andersen
> --
> You received this message because you are subscribed to the Google Groups
> "Specification by Example" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/specificationbyexample/-/nKF4oMTtNE8J.