Skip to main content
Add book author name
Source Link
bdsl
  • 4k
  • 1
  • 21
  • 19

When I am using the classical style of unit testing, how do I keep the number of test cases for an object that has many collaborators from growing too large? And how do I keep the setup of each test case from growing too large?

The author ofIn Unit Testing Principles, Practises, and Patterns, Vladimir Khorikov recommends I use the classical style of unit testing, which means testing "units" of behaviour and not using test doubles to isolate the object that I am testing from other objects that it depends on.

When I do not use test doubles to isolate my objects from each other, it seems an object near the top of my object graph that is responsible for coordinating several other objects in order to validate input, persist some data, and send an email requires many unit tests, each with a lengthy test setup, because there are many possible combinations of input and thus many possible outcomes that must be tested.

I have difficulty understanding and maintaining the tests of an object with a large number of unit tests, each of which differs only slightly from the other test cases in the same file.

However, getting rid of one or more test case creates the possibility that the object I am testing has a bug that is only discoverable when testing that scenario.

The classical school states that it’s unit tests that need to be isolated from each other, not units. Also, a unit under test is a unit of behavior, not unit of code. Only shared dependencies should be replaced with test doubles. Shared dependencies are dependencies that provide means for tests to affect each other’s execution flow.

https://freecontent.manning.com/what-is-a-unit-test-part-2-classical-vs-london-schools/

When I am using the classical style of unit testing, how do I keep the number of test cases for an object that has many collaborators from growing too large? And how do I keep the setup of each test case from growing too large?

The author of Unit Testing Principles, Practises, and Patterns recommends I use the classical style of unit testing, which means testing "units" of behaviour and not using test doubles to isolate the object that I am testing from other objects that it depends on.

When I do not use test doubles to isolate my objects from each other, it seems an object near the top of my object graph that is responsible for coordinating several other objects in order to validate input, persist some data, and send an email requires many unit tests, each with a lengthy test setup, because there are many possible combinations of input and thus many possible outcomes that must be tested.

I have difficulty understanding and maintaining the tests of an object with a large number of unit tests, each of which differs only slightly from the other test cases in the same file.

However, getting rid of one or more test case creates the possibility that the object I am testing has a bug that is only discoverable when testing that scenario.

The classical school states that it’s unit tests that need to be isolated from each other, not units. Also, a unit under test is a unit of behavior, not unit of code. Only shared dependencies should be replaced with test doubles. Shared dependencies are dependencies that provide means for tests to affect each other’s execution flow.

https://freecontent.manning.com/what-is-a-unit-test-part-2-classical-vs-london-schools/

When I am using the classical style of unit testing, how do I keep the number of test cases for an object that has many collaborators from growing too large? And how do I keep the setup of each test case from growing too large?

In Unit Testing Principles, Practises, and Patterns, Vladimir Khorikov recommends I use the classical style of unit testing, which means testing "units" of behaviour and not using test doubles to isolate the object that I am testing from other objects that it depends on.

When I do not use test doubles to isolate my objects from each other, it seems an object near the top of my object graph that is responsible for coordinating several other objects in order to validate input, persist some data, and send an email requires many unit tests, each with a lengthy test setup, because there are many possible combinations of input and thus many possible outcomes that must be tested.

I have difficulty understanding and maintaining the tests of an object with a large number of unit tests, each of which differs only slightly from the other test cases in the same file.

However, getting rid of one or more test case creates the possibility that the object I am testing has a bug that is only discoverable when testing that scenario.

The classical school states that it’s unit tests that need to be isolated from each other, not units. Also, a unit under test is a unit of behavior, not unit of code. Only shared dependencies should be replaced with test doubles. Shared dependencies are dependencies that provide means for tests to affect each other’s execution flow.

https://freecontent.manning.com/what-is-a-unit-test-part-2-classical-vs-london-schools/

Bumped by Community user
Source Link
dbird
  • 159
  • 3

How to write maintainable unit tests using classical style of unit testing

When I am using the classical style of unit testing, how do I keep the number of test cases for an object that has many collaborators from growing too large? And how do I keep the setup of each test case from growing too large?

The author of Unit Testing Principles, Practises, and Patterns recommends I use the classical style of unit testing, which means testing "units" of behaviour and not using test doubles to isolate the object that I am testing from other objects that it depends on.

When I do not use test doubles to isolate my objects from each other, it seems an object near the top of my object graph that is responsible for coordinating several other objects in order to validate input, persist some data, and send an email requires many unit tests, each with a lengthy test setup, because there are many possible combinations of input and thus many possible outcomes that must be tested.

I have difficulty understanding and maintaining the tests of an object with a large number of unit tests, each of which differs only slightly from the other test cases in the same file.

However, getting rid of one or more test case creates the possibility that the object I am testing has a bug that is only discoverable when testing that scenario.

The classical school states that it’s unit tests that need to be isolated from each other, not units. Also, a unit under test is a unit of behavior, not unit of code. Only shared dependencies should be replaced with test doubles. Shared dependencies are dependencies that provide means for tests to affect each other’s execution flow.

https://freecontent.manning.com/what-is-a-unit-test-part-2-classical-vs-london-schools/