Automated tests when using middleware validation #69
-
This question is perhaps not exclusive to this package but in general with this kind of middleware validation design. In short - is it an issue that the mutation/query-method itself does not do the validation? So, when simply calling the method with invalid inputs it goes through. And the validation has to be tested seperately. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Same thing as you will instantiate new controller directly and pass to its method something... Invalid That is because you want to test not only method itself, but full pipeline instead: mvc action filters, hotchocolate middleware, asp net core request middleware, masstransit events, etc It is integration testing and some frameworks has testing support: HotChocolate also can execute full pipeline for integration testing. From parsing, procrssing to serializing response. Here is an example: |
Beta Was this translation helpful? Give feedback.
Same thing as you will instantiate new controller directly and pass to its method something... Invalid
That is because you want to test not only method itself, but full pipeline instead: mvc action filters, hotchocolate middleware, asp net core request middleware, masstransit events, etc
It is integration testing and some frameworks has testing support:
https://www.nuget.org/packages/Microsoft.AspNetCore.Mvc.Testing
https://www.nuget.org/packages/MassTransit.TestFramework/7.2.0-develop.65
HotChocolate also can execute full pipeline for integration testing. From parsing, procrssing to serializing response. Here is an example:
AppAny.HotChocolate.FluentValidation/tests/AppAny.HotChocolat…