Strategies
- TDD (Test Driven Development)
- DDT (Data-driven testing)
- BDT (Behavioral Driven testing)
- KDT (Keyword Driven Testing)
Data-driven testing is a way of developing automated tests where the input data and expected results are taken outside the test case and stored outside it — in a file, database.
The same test case can be repeated many times with different data.
Development of testing ideas under data management and keywords
Behavior-driven testing is way of developing automated tests where the focus is on the correctness of business scenarios rather than on individual details of application functioning.
Test case behavior specification is taken outside the test case.
Keyword-driven testing is a way of developing automated tests where not only the input data and expected results are taken outside the test case but also the logic of the test case behavior, which is described by keywords (commands).
TTD
- WHAT? Wiring tests before writing the code
- HOW?
- Add a test that captures the programmer’s concept of the desired functioning of a small piece of code
- Run the test, which should fail since the code doesn’t exist
- Write the code and run the test in a tight loop until the test passes
- Refactor the code after the test is passed, re-running the test to ensure it continues to pass against the refactored code
- Repeat this process for the next small piece of code, running the previous tests as well as the added tests
- WHY? It helps developers focus on clearly-defined expected results.
- TDD reduces the number of bugs in production and improves code quality
BDD
- WHAT? Behavior-driven development allows a developer to focus on testing the code based on the expected behavior of the software. Writing use cases in natural language or in business language.
- Because the tests are based on the exhibited behavior of the software, the tests are generally easier for other team members and stakeholders to understand.
- TDD vs BDD
- So to clarify, BDD and TDD are different-but-complementary approaches. It is NEVER a choice of "one or the other", though sometimes the two approaches blend together a little.
- BDD is a collaborative methodology where the whole team has conversations about features. They explore business rules and examples, identify key acceptance criteria, and build up a shared understanding of what the feature needs to do. The acceptance criteria can be recorded in a structured-but-readable notation that we call "executable specifications", and these act as a starting point for development.
- GIVEN, WHEN, THEN, Feature, Scenario
- Gherkin is a Business Readable, Domain Specific Language created especially for behavior descriptions. It gives you the ability to remove logic details from behavior tests. Gherkin serves two purposes: serving as your project's documentation and automated tests.
- TDD is a development (design) practice that involves writing low-level executable specifications that describe what a class or component should do, in the form of unit tests, before writing the actual code.
- Python: Behave, https://behave.readthedocs.io/en/stable/
DDT
- WHAT? Tests are managed by data.
- HOW? Test data is saved separately from tests, stored in database for example.
- WHY? Used when we need to test in different environments. Different data can use the same script.
KDT
- WHAT? Tests are controlled by keywords, describes the set of actions needed for performing some action.
- HOW? We chose common keywords, write functions (click mouse, open page, …)
- Selenium, Robot are KDT frameworks
- BDD is as much about the interactions between the various people in the project as it is about the outputs of the development process. Keyword driven testing is a way of achieving the BDD approach in testing, you can define the behavior of a system using keyword.