Alternatives to the Pipes and Filters pattern

465 Views Asked by At

Modifying and tying to test the 7th filter out of a chain of 11 filters proves to be painful to test. I have to do an integration test from Filter#1 to Filter #11 to make sure Filter#7 works properly.

Each filter passes along the same object reference and they work on it. So for me, I have no idea what kind of state this object would be in when I receive it in the 7th filter that I'm modifying.

There isn't much documentation. So I don't really know what state I'm getting.

Are there any other ways to replace the Pipes and Filters pattern in general? I'm looking for a good way suitable for unit testing.

https://learn.microsoft.com/en-us/azure/architecture/patterns/pipes-and-filters

The way this programme that I'm working on is arranged seems like each filter relies on the output of the previous filter. And the filters are added in a specific order. The filters cannot be rearranged in a different order.

1

There are 1 best solutions below

0
jaco0646 On

I have to do an integration test from Filter#1 to Filter #11 to make sure Filter#7 works properly.

Even if a test of 1-11 passes, you are ultimately testing the output of 11, not the output of 7.

There are three basic levels of developer testing: system, integration, unit. A test of all 11 filters would be a system test, also called an end-to-end test. Testing a subset of filters together would be integration testing. Testing filter 7 alone would be unit testing.

To perform unit testing, you must mock the input to filter 7. This mock input has nothing to do with filters 1-6 and everything to do with the specification (requirements) of filter 7.

If you do not know the requirements of filter 7, you cannot unit test filter 7. Replacing the pipe-and-filter pattern will not aid in testing unknown requirements.