Keyboard Shortcuts
Likes
Search
Tests more complex than the solution they drive
I am currently working on what you could categorise as a workflow automation product. The product is comprised of independently deployed front and back end components.
Using mediator, every element of the solution is broken down into sets of 3 classes, request, handler and result.? Requests and results are POCOs whilst handlers implement behaviour and require few dependencies. ?Often, in cases where the only job to do is orchestrate the sending and receiving of requests and results, the sole dependency is the mediator type itself.? Other requests fall into the two categories of query or command.
This is achieved by gathering and then issuing a collection of steps, where each step is a high-level mediator message, as the “Given”s and “When”s of a test scenario.? During the “Then” assertions are made against the result POCOs that were observed by a stub implementation of the mediator type, e.g. assert that the last created entity of type “A” should have such and such an “A.Name”.
|
开云体育I’m a bit confused by your description, as it sounds as though you are doing system tests. That’s the most obvious case in which you’d need to “replay all the steps the application would theoretically take in order to reach the point whereby the query can return sensible results.” One of the advantages of unit tests is that you don’t do that, as you are testing each small part of the system.Is the problem that even the small parts have to be brought to a state via complex steps?? Russ ----------------- Author,?Getting Started with Apache Maven <> Author, HttpUnit <> and SimpleStub <> Now blogging at <> Have you listened to Edict Zero <>? If not, you don’t know what you’re missing!
|
The in solution 'framework' that has evolved for these tests does have a bit of a system test feel to it, although it is being leant on to test drive new classes with new behaviours. [Fact] ? ? .Given(builder => builder ? ? ? .UserCreatesEntityA("Entity A") ? ? ? .UserCreatesEntityB("Entity B",?new[]?{?new DetailForB { Name = "Detail B"},?}) |
Rob Park
For me, it's great that you have 2 independently deployable pieces. Though I would ensure I also had independently runnable tests. With the exception of having contract tests to test your expectations of the backend interactions. This will have benefits of being easier to reason about (at least once you start to feel comfortable with the concept); faster test suites; less brittle maintenance. In a similar setup to what you have, I've had?end-to-end system tests in the past, but I literally only had 1 or 2 validating the most important use case still worked after each deploy (of either side). Good luck! On Mon, Sep 7, 2020 at 7:17 AM paulnmackintosh <pnm@...> wrote:
|
Do you have common use cases where you can use the builder pattern to create the context? Or is the set of steps different in each scenario? brought to you by the letters A, V, and I and the number 47 On Mon, Sep 7, 2020 at 4:55 PM Rob Park <robert.d.park@...> wrote:
|
Yes, I can see a fair number of tests that are currently using common setup steps.? These could be encapsulated at a higher level of abstraction and doing so will remove duplication in the test code.? I wonder if this will lead to slow test execution over time though as it will manage complexity consistently rather than reduce it.
|
开云体育Is it possible to place an object in a desired state without all of the builder steps? If so, you could then give it stimuli and test just single state transitions. I would be concerned, if I worked on a system like this, than the testing time would become rather problematic.
|
toggle quoted message
Show quoted text
On Sep 7, 2020, at 3:10 AM, paulnmackintosh <pnm@...> wrote:
|
It depends, query handlers tend to have a repository interface injected, the repository encapsulates the EF LINQ in a read only way.? Command handlers will generally perform operations on EF collections using methods exposed on the Domain Entities and then saving the changes.? Orchestrating handlers, in theory, shouldn't need to modify entities, their job is to pass query results to command handlers.
|