Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought
Software testing
Software Testing
Software testing Software Testing Introduction Testing levels - - PowerPoint PPT Presentation
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought Software testing Software Testing Introduction Testing levels Automated testing Principles and testability Coverage Criteria
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought
Software testing
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought
Programmers! Cast out your guilt! Spend half your time in joyous testing and debugging! Stalk bugs with care, methodology, and
bugs and taste the joys of guiltless programming! – Boris Beizer
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought
Testing maturity (Beizer 1990)
1 testing is just for debugging 2 testing is to show correctness of the product 3 testing is to show incorrectness of the product 4 testing is to reduce risk 5 testing is a mental discipline to develop better software
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought
Kinds of testing
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought Terminology
Functional testing – terminology
What is it we are looking for? Bugs, faults, errors, failures?
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought Terminology
Terminology
public static int numZero(int[] x) { int count = 0; for (int i = 1; i < x.length; i++) { if (x[i] == 0) count++; } return count; }
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought Terminology
The RIPR model
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought Terminology
The RIPR model
Four conditions necessary for a failure to be observed:
fault must be reached.
final part of the program to be incorrect.
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought
Traditional testing levels
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought
The V-model
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought
Unit and module testing
Testing correctness of individual units of code. Manual: void test validation() { do { string num = input("Type account number: "); println("Result: " + validate account(num)); } }
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought
Unit and module testing
Testing correctness of individual units of code. Automatic:
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought
Unit and module testing
possible branch (aka test coverage)
black box
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought
Integration testing
Verifying that different software modules work in unity.
into the main software package
functionality
black box (but typically black box)
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought
Integration testing
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought
Kinds of integration testing
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought
System testing
Testing documented requirements of the fully integrated software.
agent
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought
Acceptance testing (or: beta-testing)
Testing usability by actual users.
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought
Designing automated tests
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought
Automated unit testing
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought Test doubles
Mocking, stubbing, etc.
int get random number() { return 42; }
void send mail() { sent++; }
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought Test doubles
Mocking, stubbing, etc.
Cook ⇐ = Waiter ⇐ = CustomerTest driver
actually asked
request and given a hamburger to return, and will start screaming if asked for a hot dog
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought General advice
Side benefits of automated unit testing
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought General advice
Unit testing advice
assertEquals("adding one day to 2050/2/15", expected, actual);
@Test(timeout = 5000)
(use @Before and @After for setup and teardown functions)
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought General advice
Unit tests – things to think about
have the same problem.
not representative.
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought General advice
Unit tests – things to think about
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought General advice
Manual versus automatic testing
repetition
automatically
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought
Recall: software design principles
Satisfying these principles makes the code more testable! Both because it allows units to be tested separately (and without unnecessary side effects), and because good use of principles makes it easier to mock certain objects like low-level classes or third-party components.
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought
Class exercise: designing testable code
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought
Class exercise: designing testable code
The input window:
right arrow keys, entering commands, selecting, etc.).
selected (for easy deleting).
previously sent lines.
and this position is selected.
position to go to the bottom.
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought
Class exercise: designing testable code
Naive implementation:
Better implementation:
responsibility. Best implementation:
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought
Class exercise: designing testable code
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought
Class exercise: designing testable code
Note:
and no dependencies. It is easy to test automatically.
three classes that interacts with the outside world (e.g., giving events when return is pressed).
InputWindowTextField by replacing these two by fake, stub or mock objects. For example: call InputWindow.specialKeyEvent to indicate that return was pressed, and test whether it sends the text in the textfield stub on the event bus and passes it into the history spy.
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought
Class exercise: designing testable code
Note:
test framework, this may require manual testing. This can still be done systematically: define manual tests, and agree that they are executed whenever someone changes the component.
the relevant GUI component, can be questioned for active text, and passes on requested key events. Because it is so small, it will rarely need changing, and only minimal testing.
InputHistory: it is simply given an object to which it must pass special key events and componentChanged() notifications. This makes it easier to systematically test it in isolation.
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought
Some Considerations
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought TDD
Test-Driven Development
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought TDD
Principles of TDD
(ATDD)
(but boy scout rule)
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought Mutation testing
Recall: the RIPR model
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought Mutation testing
Mutation testing: considering the P in RIPR
Basic idea:
test set.
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought Testing roles
Erroneous perception
“I’ll just find the bugs by running the client program.” Too often:
Definition of done: includes testing!
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought Testing roles
Tasks in testing:
Each type of activity requires different skills, background, knowledge, education and training!
Software Testing
Introduction Testing levels Automated testing Principles and testability Coverage Criteria Points for thought Principles
Principles of testing
(So you’ll have to do risk assessment and try to find a representative sample of test cases.)
modules.
Software Testing
By Joren Vrancken
My idea PR Review by peer Manual testing* Manual testing* Code review master Commits
*manually testing changes and manually running unit/integration/etc tests.
My idea PR Review by peer Manual testing* Manual testing* Code review master Commits
*manually testing changes and manually running unit/integration/etc tests.
PR Review by peer Manual testing Code review master
○ Codestyle mistakes are easily overlooked
○ Easy to forget something ○ Different views between reviewers ○ “This is so simple, I don’t have to test it”
○ Different operating systems, laptops, etc. etc.
Automated tasks on your codebase that run under certain conditions.
○ Similar to the production environment
My idea PR Review by peer Manual testing Manual testing Code review master Commits CI Testing
1. Pineline: Ordered stages 2. Stage: One or more jobs 3. Jobs: Ordered steps to reach a goal
Linting Check documentation Unit tests Integration tests Build Docker image Check translations Static Checks Test Build
○ Under specific conditions (e.g. only on the master branch)
○ Distributable ○ Define steps using Unix commands, Javascript or Docker images ○ Execute jobs on events (e.g. starring, first contributor)
Demonstration