Domanda

Should we classify BDD tests as "unit tests" or "integration tests" ("assembly tests" or "string tests")? Confused because technically BDD tests are run with *unit tools, though the tests might (and in most cases) cover several components as they would possibly be used to test use cases end-to-end.

È stato utile?

Soluzione

BDD doesn't have just one kind of test. It uses both acceptance tests and unit tests.

It starts with acceptance tests. The purpose of acceptance tests is to define and verify application features at a high level. Acceptance tests are usually written with a BDD tool like JBehave or Cucumber, not with a unit-testing tool. You could write acceptance tests with a unit-testing tool, but that doesn't work as well as using a real BDD tool, because unit-testing tools mix specification and implementation in the same file, making it harder to focus on the behavior. Technically, acceptance tests are integration tests, because they run against the entire application stack.

Once acceptance tests are implemented, BDD moves on to testing that defines and verifies the details of the desired application behavior and ensures technical correctness.

  • Additional integration tests might be written using the same tool as acceptance tests or might be written with a unit-testing tool but without isolating application layers. Even if they're written using the same tool as acceptance tests, they're just integration tests, because they're motivated by requirement details and engineering concerns, not by high-level requirements.

  • BDD also uses regular unit tests to test requirement details and technical concerns.

A typical BDD test suite includes a full suite of acceptance tests, a limited number of integration tests (other than acceptance tests), and a large number of unit tests. Application layers close to the user (e.g. controllers) are often tested mostly or entirely in the acceptance tests, while lower layers (e.g. models) need more unit tests.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top