Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 134355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:35:54+00:00 2026-05-11T06:35:54+00:00

Imagine a system of filters (maybe audio filters, or text stream filters). A Filter

  • 0

Imagine a system of filters (maybe audio filters, or text stream filters).

A Filter base class has a do_filter() method, which takes some input, modifies it (perhaps), and returns that as output.

Several subclasses exist, built with TDD, and each has a set of tests which test them in isolation.

Along comes a composite class, of an unrelated type Widget, which has two members of different Filter types (a and b), which deal with quite different input – that is, certain input which would be modified by filter a is passed through unmodified by filter b, and vice versa. Its process_data() method calls each filter member’s do_filter().

While developing the composite class, there emerge tests that check the assumption that Widget‘s filters aren’t both processing the same data.

The problem is, these sort of tests look identical to the individual filter’s test. Although there might be other tests, which test input which should be modified by both filters, many of the tests could almost be copied and pasted from each of the filter’s tests, with only small modifications needed to have them test with Widget (such as calling process_data()), but the input data and the assert checks are identical.

This duplication smells pretty bad. But it seems right to want to test the components’ interactions. What sort of options will avoid this sort of duplication?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T06:35:54+00:00Added an answer on May 11, 2026 at 6:35 am

    Within one Test suite/class have a method

    public void TestForFooBehaviour(IFilter filter)  {     /* whatever you would normally have in a test method */ } 

    Then invoke this method from both the original test on the simple filter as well as from the composite filter. This also works for abstract base classes. Obviously FooBehaviour should be a meaningful description of the aspect of filters you are testing. Do this for each behaviour you want to test.

    If you language supports duck typing or generics feel free to use it if it helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 59k
  • Answers 59k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Solved the problem by using Chris Pietschmann's instructions to Convert… May 11, 2026 at 9:02 am
  • added an answer If you're creating stuff and then passing it to be… May 11, 2026 at 9:02 am
  • added an answer In Script.aspx.cs, you can simply check the Request.Path in comparison… May 11, 2026 at 9:02 am

Related Questions

Imagine having the following scenario: You need to create a system where the Back
I have a problem: imagine I have a plugin-based system. I need some kind
Imagine a web application written in Ruby on Rails. Part of the state of
Imagine a DOS style .cmd file which is used to launch interdependent windowed applications
Imagine a base class with many constructors and a virtual method public class Foo
Imagine a Java client/server ERP application serving up to 100 concurrent users, both web
Imagine a scenario where, using xml, the user is able to specify ranges in
Imagine a situation, I have PC with two lan cards, one is connected to
Some context upfront: Imagine a 200+ developers company finally setting up a more or
For explanation imagine a simple address. Written in a HTML paragraph with line breaks

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.