2

The way TDD has been described to me makes it sound like TDD is only really useful with unit testing. Does TDD mean all types of testing, such as Acceptance testing, and functional tests?

3 Answers 3

1

TDD focuses on very small pieces of code. Classes or methods or (in some cases) very small groups of tightly collaborating objects.

There are test-driven techniques that focuses on a larger scope. Two of these are Acceptance Test Driven Development (ATDD) and Behavior Driven Development (BDD). To my eye, these approaches are similar in intent, though BDD tends to give more emphasis on a particular style of test automation (namely the Given/When/Then style).

What is common between ATDD and BDD is that they start with examples of the whole system's functionality. These examples usually constitute a large subset of the acceptance tests for the system. In contrast, the tests in TDD focus on the functionality of tiny parts of the system.

Mostly I've seen TDD, ATDD, and BDD focusing on functionality.

I myself would not rely solely on automated tests, though there are people who advocate that. I prefer to combine automated tests with exploratory testing.

I have not seen these approaches used for performance testing or security testing, though I suspect some aspects of performance and security testing can be automated. Those are domains where I would want experts to do the testing with their brains fully engaged.

1

Test Driven Development (TDD) is a product development method that is a combination of unit-testing, development and evaluating code. In TDD, each functionality has its own unit test cases---a tester tests it first and if they find any bugs then the code is rewritten. The main goal of TDD is to make all test cases bug-free.

The first step of TDD is to write test cases for each of the small modules. Then, all the test cases are executed. If a defect is found, we go to the second step: coding. Once the code is refactored, we start with step 1 again. This process goes on until there are zero defects.

You can use TDD with all types of testing: unit-testing, black-box testing, white-box testing etc. If you use Static Application Security Testing (SAST) with Test Driven Development (TDD), it is called Security Test Driven Development (STDD). STDD is a testing process used to find security vulnerabilities. You can use ready-to-use tools to write and run STDD test cases. These types of tools are designed to scan the product's base code and design flow so that they can detect security vulnerabilities easily.

The testing cycle in STDD is similar to that of TDD. You start with the same first step of writing test cases, but here your main focus is on security. The STDD method prompts the developer to update their code where it is lacking in terms of security in order to make it invulnerable to attackers trying to gain unauthorized access.

The Security Test-Driven Development Process**:**

  • Check code and do a basic security scan
  • Write all test cases mainly from a security angle
  • Run all test cases
  • Check if any test cases failed and found security vulnerabilities
  • If any test failed, rewrite the code
  • Re-check failed test cases 
  • Repeat the process until the code passes all test cases
0

For functional/acceptance testing you need working application, so TDD is much better match for unit testing. But you can plan for functional/acceptance testing, and those test plans may influence your design decisions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.