Skip to main content
added 186 characters in body
Source Link
candied_orange
  • 119.7k
  • 27
  • 233
  • 369

Let me show you my favorite unit test principles:

A test is not a unit test if:

  1. It talks to the database 0. It communicates across the network 0. It touches the file system 0. It can't run at the same time as any of your other unit tests 0. You have to do special things to your environment (such as editing config files) to run it.

A Set of Unit Testing Rules - Michael Feathers

If your unit test insists that it be the "main thread" it's hard not to run afoul of number 4.

This may seem harsh but remember that a unit test is just one of many different kinds of tests.

enter image description here

You're free to violate these principles. But when you do, don't call your test a unit test. Don't put it with the real unit tests and slow them down.

Let me show you my favorite unit test principles:

A test is not a unit test if:

  1. It talks to the database 0. It communicates across the network 0. It touches the file system 0. It can't run at the same time as any of your other unit tests 0. You have to do special things to your environment (such as editing config files) to run it.

A Set of Unit Testing Rules - Michael Feathers

If your unit test insists that it be the "main thread" it's hard not to run afoul of number 4.

Let me show you my favorite unit test principles:

A test is not a unit test if:

  1. It talks to the database 0. It communicates across the network 0. It touches the file system 0. It can't run at the same time as any of your other unit tests 0. You have to do special things to your environment (such as editing config files) to run it.

A Set of Unit Testing Rules - Michael Feathers

If your unit test insists that it be the "main thread" it's hard not to run afoul of number 4.

This may seem harsh but remember that a unit test is just one of many different kinds of tests.

enter image description here

You're free to violate these principles. But when you do, don't call your test a unit test. Don't put it with the real unit tests and slow them down.

Source Link
candied_orange
  • 119.7k
  • 27
  • 233
  • 369

Let me show you my favorite unit test principles:

A test is not a unit test if:

  1. It talks to the database 0. It communicates across the network 0. It touches the file system 0. It can't run at the same time as any of your other unit tests 0. You have to do special things to your environment (such as editing config files) to run it.

A Set of Unit Testing Rules - Michael Feathers

If your unit test insists that it be the "main thread" it's hard not to run afoul of number 4.