F7 Flashcards
State-Based Testing
• Model functional behavior in a state machine (communication – protocol …)
• Select test cases in order to cover the graph
– Each node
– Each transition
– Each pair of transitions
– Each chain of transitions of length n
States are Behavioral Modes
Three questions to detect/recognise states:
- AretherethingsIcandonowthatIcouldnot do before?
- AretherethingsIcannotdonowthatIcould do before?
- Willmyactionshavedifferentresultsnow than before?
State models (diagrams)/State tables
- Statemodelspromptyoutoconsider(state) transitions.
- Statetablespromptyoutoconsiderwhenyoucause events to occur outside the bounds of expected transitions.
- Asaresult,statetablesareparticularlygoodfor discovering problems related to interruptions or unhandled transitions.
- Considere.g.thereturnvalueforthe“invalidcases” in the table.
All pairs
based on the observation that most faults are caused by
interactions of at most two factors.
– A method often used for testing of combinations of input is “All Pairs”. The method does not bother to analyse the logical dependencies (e.g. using Cause-Effect graphing), but tries to list test cases, that pair each value of each of the variables with each value of each other variable at least once.
Cyclomatic Complexity
Cyclomatic number of test cases to fully cover a piece of code. of the needed Complexity can be used as an indication
Condition coverage
To cover all conditions, we need to make sure that “each Boolean sub-expression has been evaluated both to true and false at least once”.
Coverage-based Testing • Advantages
– Systematic way to develop test cases – Measurable results (the coverage) – Extensive tool support • Flow graph generators • Test data generators • Bookkeeping • Documentation support
Coverage-based Testing disadvantages
– Code must be available
What Can’t White Box Tests Find?
• Bugsofomission
– Missing requirements, design elements, code
• Use requirements, design and code reviews • Unmaintainable code
– Inscrutable variable names or constructs, etc. • Use code reviews and static analysis tools
• Systemicproblems
– Performance, security, usability, interoperability, etc.
• Use code reviews, black-box system testing, beta/pilot tests, usability studies, prototyping, etc.
Automated testing
unit testing should be automated so that tests are run and checked without manual intervention.
• With automated tests, the test suite can be rerun whenever there has been a change to the SW. One can then see if the new code has made any of the previously passing test cases to now fail.
• In automated unit testing, you make use of a test automation framework (such as Junit/NUnit) to write and run your program tests.
Test-Driven Development
is an approach to program development in which you inter-leave testing and code development.
• Tests are written before code and ‘passing’ the tests is the critical driver of development.
• You develop code incrementally, along with a test for that increment. You don’t move on to the next increment until the code that you have developed passes its test.
Benefits of test-driven development
Writing the test first, forces you to consider what the new code shall do. This often leads to better structured code (remember the “single responsibility principle”)
• Code coverage
– Every code segment that you write has at least one associated
test so all code written has at least one test.
• Regression testing
– A regression test suite is developed incrementally as a program is developed.
• Simplified debugging
– When a test fails, it should be obvious where the problem lies.
The newly written code needs to be checked and modified. • System documentation
– The tests themselves are a form of documentation that describe what the code should be doing.