1DV609 Test Generation
From Requirements and code
Testing Requirements
Requirements pyramid
Requirement Coverage & Pyramid
Example: User wants to get access to a restricted access. �User request access. System asks for credentials. User gives credentials. System verifies credentials and presents restricted access.
Alternative. User gives invalid credentials. System presents that the credentials are invalid.
Testing Requirements
Example: From Use-Case Scenarios
Find all scenarios? Path coverage!
Example
UC1 Authenticate user
Main scenario
Alternate Scenarios
3a. User wants the system to keep user credentials for easier login.
4a. User could not be authenticated
1
2
3
4
3a
4a
Test traceability
Verify implementation
Change management
Requirement-Coverage
Test-Traceability-Matrix http://en.wikipedia.org/wiki/Traceability_matrix
Testing Non Functional Requirements
Types of non-functional testing
http://en.wikipedia.org/wiki/Non-functional_testing
Examples: Compatibility testing, Compliance testing, performance testing, load testing, scalability testing, localization testing, security testing, usability testing, accessibility testing (WCAG).
Set realistic goals!
Many of these need specialized tools, manual processes.
Exempel
https://www.digg.se/kunskap-och-stod/digital-tillganglighet
(also available in English, see top right corner)
Load testing tools
What is the ideal test suite?
Coverage
Finds bugs if there are bugs
Automated to reduce painful regression
Easy to change when requirements change
Quick to develop, and can be used during development.
Minimal test suite that still gives us “enough” confidence.
Good enough for acceptance testing (customer “sign of” an iteration/sprint)
Assumptions are made to minimize work
We want these assumptions to be as informed as possible.
For example we only regression test modules that have changed...
Black box testing
Examine functionality from the outside without knowing anything of the internals.
Tests are generated from specification.
Equivalence Partitioning
Divide the input into equivalent disjoint subsets
https://en.wikipedia.org/wiki/Equivalence_partitioning
Example:
public void addUser(int age)�Divide into valid input and invalid input.�
For example age in [0,120]�“name” must be have length [1,100]
max
/**�* Returns the largest of three inputs�* All inputs must be positive numbers >= 0�* Throws exception on negative numbers�**/�int maxOfThree(int a, int b, int c) {...}
White(or. Glass) box testing
Testing with knowledge of code internal workings.
Behaviour
Ex. coverage.
Tests are generated from source code.
Equivalence Partitioning?
public synchronized String read() {
if (buffer.contains("\n")) {
int at = buffer.indexOf('\n');
String ret = buffer.substring(0, at+1);
buffer = buffer.substring(at+1);
return ret;
}
return "";
}
Multiple Partitions
Customers of age 18-65 gets loan if their salary exceeds 25K £ / year
public boolean getLoan(int age, int salary)
public boolean getLoan(int age, int salary)
Boundary Value Analysis
Based on common mistakes by programmers...
Overkill?