Skip to main content
added 8 characters in body
Source Link
Doc Brown
  • 214.2k
  • 34
  • 394
  • 603

I have read that the changes to the code base should not change the unit tests.

Let me say this straight: this makes no sense.

I don't have that book at hand, and you did not tell us which section lead you to this interpretation, still I am convinced you must have misread something. Unit tests (as well as any other kind of test) will not be required to change when an implementation of a certain (externally visible) behaviour changes, as long as the desired behaviour itself stays the same. But when the implementation changes up to the point where the desired behaviour changes, then the tests for this behaviour obviously have to change as well.

For example, different implementations of ConsoleGreetingService.ShowGreeting like

Console.WriteLine("Hello!");

or

const string greetings = "Hello!";
Console.WriteLine(greetings);

or

Console.WriteLine(GetHelloInCertainLanguage(new CultureInfo("en")) + "!");

can all be subject to the same, unchanged test which verifies the expected string is printed to the console.

Replacing a console output by some GUI output, however, is a change which obviously changes the externally visible behaviour, hence there is no reason to assume tests don't have to be changed.

Side note: how to implement a test which verifies that a certain message box with a certain text will be shown, and if it is justified call such a test a "unit test" is a separate topic which I don't discuss here.

I have read that the changes to the code base should not change the unit tests.

Let me say this straight: this makes no sense.

I don't have that book at hand, and you did not tell us which section lead you to this interpretation, still I am convinced you must have misread something. Unit tests (as well as any other kind of test) will not be required to change when an implementation of a certain (externally visible) behaviour changes, as long as the behaviour itself stays the same. But when the implementation changes up to the point where the behaviour changes, then the tests for this behaviour obviously have to change as well.

For example, different implementations of ConsoleGreetingService.ShowGreeting like

Console.WriteLine("Hello!");

or

const string greetings = "Hello!";
Console.WriteLine(greetings);

or

Console.WriteLine(GetHelloInCertainLanguage(new CultureInfo("en")) + "!");

can all be subject to the same, unchanged test which verifies the expected string is printed to the console.

Replacing a console output by some GUI output, however, is a change which obviously changes the externally visible behaviour, hence there is no reason to assume tests don't have to be changed.

Side note: how to implement a test which verifies that a certain message box with a certain text will be shown, and if it is justified call such a test a "unit test" is a separate topic which I don't discuss here.

I have read that the changes to the code base should not change the unit tests.

Let me say this straight: this makes no sense.

I don't have that book at hand, and you did not tell us which section lead you to this interpretation, still I am convinced you must have misread something. Unit tests (as well as any other kind of test) will not be required to change when an implementation of a certain (externally visible) behaviour changes, as long as the desired behaviour itself stays the same. But when the implementation changes up to the point where the desired behaviour changes, then the tests for this behaviour obviously have to change as well.

For example, different implementations of ConsoleGreetingService.ShowGreeting like

Console.WriteLine("Hello!");

or

const string greetings = "Hello!";
Console.WriteLine(greetings);

or

Console.WriteLine(GetHelloInCertainLanguage(new CultureInfo("en")) + "!");

can all be subject to the same, unchanged test which verifies the expected string is printed to the console.

Replacing a console output by some GUI output, however, is a change which obviously changes the externally visible behaviour, hence there is no reason to assume tests don't have to be changed.

Side note: how to implement a test which verifies that a certain message box with a certain text will be shown, and if it is justified call such a test a "unit test" is a separate topic which I don't discuss here.

added 10 characters in body
Source Link
Doc Brown
  • 214.2k
  • 34
  • 394
  • 603

I have read that the changes to the code base should not change the unit tests.

Let me say this straight: this makes no sense.

I don't have that book at hand, and you did not tell us which section lead you to this interpretation, still I am convinced you must have misread something. Unit testtests (as well as any other kind of test) will not be required to change when an implementation of a certain (externally visible) behaviour changes, as long as the behaviour itself stays the same. But when the implementation changes up to the point where the behaviour changes, then the tests for this behaviour obviously have to change as well.

For example, whether thedifferent implementations of ConsoleGreetingService.ShowGreeting is implemented like

Console.WriteLine("Hello!");

or

const string greetings = "Hello!";
Console.WriteLine(greetings);

or

Console.WriteLine(GetHelloInCertainLanguage(new CultureInfo("en")) + "!");

should not require any changecan all be subject to athe same, unchanged test which verifies the expected string is printed to the console.

Replacing a console output by some GUI output, however, is a change which obviously changes the externally visible behaviour, hence there is no reason to assume tests don't have to be changed.

Side note: how to implement a test which verifies that a certain message box with a certain text will be shown, and if it is justified call such a test a "unit test" is a separate topic which I don't discuss here.

I have read that the changes to the code base should not change the unit tests.

Let me say this straight: this makes no sense.

I don't have that book at hand, and you did not tell us which section lead you to this interpretation, still I am convinced you must have misread something. Unit test (as well as any other kind of test) will not be required to change when an implementation of a certain (externally visible) behaviour changes, as long as the behaviour itself stays the same. But when the implementation changes up to the point where the behaviour changes, then the tests for this behaviour obviously have to change as well.

For example, whether the ConsoleGreetingService.ShowGreeting is implemented like

Console.WriteLine("Hello!");

or

const string greetings = "Hello!";
Console.WriteLine(greetings);

or

Console.WriteLine(GetHelloInCertainLanguage(new CultureInfo("en")) + "!");

should not require any change to a test which verifies the expected string is printed to the console.

Replacing a console output by some GUI output, however, is a change which obviously changes the externally visible behaviour, hence there is no reason to assume tests don't have to be changed.

Side note: how to implement a test which verifies that a certain message box with a certain text will be shown, and if it is justified call such a test a "unit test" is a separate topic which I don't discuss here.

I have read that the changes to the code base should not change the unit tests.

Let me say this straight: this makes no sense.

I don't have that book at hand, and you did not tell us which section lead you to this interpretation, still I am convinced you must have misread something. Unit tests (as well as any other kind of test) will not be required to change when an implementation of a certain (externally visible) behaviour changes, as long as the behaviour itself stays the same. But when the implementation changes up to the point where the behaviour changes, then the tests for this behaviour obviously have to change as well.

For example, different implementations of ConsoleGreetingService.ShowGreeting like

Console.WriteLine("Hello!");

or

const string greetings = "Hello!";
Console.WriteLine(greetings);

or

Console.WriteLine(GetHelloInCertainLanguage(new CultureInfo("en")) + "!");

can all be subject to the same, unchanged test which verifies the expected string is printed to the console.

Replacing a console output by some GUI output, however, is a change which obviously changes the externally visible behaviour, hence there is no reason to assume tests don't have to be changed.

Side note: how to implement a test which verifies that a certain message box with a certain text will be shown, and if it is justified call such a test a "unit test" is a separate topic which I don't discuss here.

Answer made more general by replacing unit test by test in a few places
Source Link
Doc Brown
  • 214.2k
  • 34
  • 394
  • 603

I have read that the changes to the code base should not change the unit tests.

Let me say this straight: this makes no sense.

I don't have that book at hand, and you did not tell us which section lead you to this interpretation, still I am convinced you must have misread something. Unit test (as well as any other kind of test) will not be required to change when an implementation of a certain (externally visible) behaviour changes, as long as the behaviour itself stays the same. But when the implementation changes up to the point where the behaviour changes, then the unit tests for this behaviour obviously have to change as well.

For example, whether the ConsoleGreetingService.ShowGreeting is implemented like

Console.WriteLine("Hello!");

or

const string greetings = "Hello!";
Console.WriteLine(greetings);

or

Console.WriteLine(GetHelloInCertainLanguage(new CultureInfo("en")) + "!");

should not require any change to a unit teststest which verifies the expected string is printed to the console.

Replacing a console output by some GUI output, however, is a change which obviously changes the externally visible behaviour, hence there is no reason to assume unit tests don't have to be changed.

Side note: how to implement a unit test which verifies that a certain message box with a certain text will be shown, and if it is justified call such a test a "unit test" is a separate topic which I don't discuss here.

I have read that the changes to the code base should not change the unit tests.

Let me say this straight: this makes no sense.

I don't have that book at hand, and you did not tell us which section lead you to this interpretation, still I am convinced you must have misread something. Unit test will not be required to change when an implementation of a certain (externally visible) behaviour changes, as long as the behaviour itself stays the same. But when the implementation changes up to the point where the behaviour changes, then the unit tests for this behaviour obviously have to change as well.

For example, whether the ConsoleGreetingService.ShowGreeting is implemented like

Console.WriteLine("Hello!");

or

const string greetings = "Hello!";
Console.WriteLine(greetings);

or

Console.WriteLine(GetHelloInCertainLanguage(new CultureInfo("en")) + "!");

should not require any change to a unit tests which verifies the expected string is printed to the console.

Replacing a console output by some GUI output, however, is a change which obviously changes the externally visible behaviour, hence there is no reason to assume unit tests don't have to be changed.

Side note: how to implement a unit test which verifies that a certain message box with a certain text will be shown, and if it is justified call such a test a "unit test" is a separate topic which I don't discuss here.

I have read that the changes to the code base should not change the unit tests.

Let me say this straight: this makes no sense.

I don't have that book at hand, and you did not tell us which section lead you to this interpretation, still I am convinced you must have misread something. Unit test (as well as any other kind of test) will not be required to change when an implementation of a certain (externally visible) behaviour changes, as long as the behaviour itself stays the same. But when the implementation changes up to the point where the behaviour changes, then the tests for this behaviour obviously have to change as well.

For example, whether the ConsoleGreetingService.ShowGreeting is implemented like

Console.WriteLine("Hello!");

or

const string greetings = "Hello!";
Console.WriteLine(greetings);

or

Console.WriteLine(GetHelloInCertainLanguage(new CultureInfo("en")) + "!");

should not require any change to a test which verifies the expected string is printed to the console.

Replacing a console output by some GUI output, however, is a change which obviously changes the externally visible behaviour, hence there is no reason to assume tests don't have to be changed.

Side note: how to implement a test which verifies that a certain message box with a certain text will be shown, and if it is justified call such a test a "unit test" is a separate topic which I don't discuss here.

deleted 1 character in body
Source Link
Doc Brown
  • 214.2k
  • 34
  • 394
  • 603
Loading
added 5 characters in body
Source Link
Doc Brown
  • 214.2k
  • 34
  • 394
  • 603
Loading
added 5 characters in body
Source Link
Doc Brown
  • 214.2k
  • 34
  • 394
  • 603
Loading
Source Link
Doc Brown
  • 214.2k
  • 34
  • 394
  • 603
Loading