06. Testing

Testing strategies != testing

Debate: developers should not test their own code/program

Developers should develop, testers should test

Negative: developers should develop and test

Positive:

Negative:

Counterpoints against positive:

Counterpoints against negative:

Quality

Quality is created by the developer - so what is testing for?

Testing isn’t about unit testing or integration testing. It is the mindset; a systematic process of:

Testing is about how a user experiences the system and how it compares to our expectations.

In what contexts is testing not required?

Hypothesis Testing

The broad steps:

Example:

Verifiability vs Falsifiability

What will it take for us to be able to claim that there are no bugs in the system?

You must test every conceivable avenue and every single branch; verify the system. This is almost impossible, although formal proofs are possible in limited domains.

Karl Popper - The Logic of Scientific Discovery, 1934.

Verifiability: every single branch can be tested

Falsifiability: at least one example that contradicts the hypothesis can be found

Hence, there is a large asymmetry between the two: when making scientific hypotheses, we find evidence to support or disprove the hypothesis but we can never prove the hypothesis is true.

Testing vs. Automation

Automations help with making the testing process easier; it is not testing itself.

Testing is the human process of thinking about how to verify/falsify.

Testing is done in context; humans must intelligently evaluate the results taking this into account.

Biases

Confirmation Bias

The tendency to interpret information in a manner that confirms your own beliefs:

Congruence Bias

Subset of confirmation bias, in which people over-rely on their initial hypothesis and neglect to consider alternatives (which may indirectly test the hypothesis).

In testing, this occurs if the tester has strategies that they use all the time and do not consider alternative approaches.

Anchoring Bias

Once a baseline is provided, people unconsciously it as a reference point.

Irrelevant information affects the decision making/testing process.

The tester is already anchored in what the system does, perhaps from docs, user stories, talks with management etc. and not consider alternate branches.

Functional fixedness: a tendency to only test in the way the system is meant to be used and not think laterally.

Law of the Instrument Bias

Believing and relying on an instrument to a fault.

Reliance on the testing tool/methodology e.g. acceptance/unit/integration testing: we use x therefore y must be true.

The way the language is written can affect it as well. e.g. the constrained syntax of user stories leads to complex information and constraints being compressed and relevant information being lost.

Resemblance Bias

The toy duck looks like a duck so it must act like a duck: judging a situation based on a similar previous situation

e.g. if you have experience in a similar framework, you may make assumptions about how the current framework works based on your prior experience. This may lead to ‘obvious’ things being missed or mistaken.

Halo Effect Bias

Brilliant people/organizations never make mistakes. Hence, their work does not need to be tested (or this bug I found is a feature, not a bug).

Authoritative Bias

Types of Testing Techniques

Static testing:

Dynamic testing:

Scripted vs unscripted tests; compared to to unscripted tests, scripted tests:

Testing Toolbox

Three main classes:

Unit testing:

Integration testing:

System testing:

Smoke testing:

Sanity testing:

Regression testing:

Acceptance testing:

End-to-end testing:

Security testing:

Test/Behavior Driven Development (TDD/BDD)

Development, NOT testing strategies.

Tests made in this process are prototypes and hence they .

TDD tests are blue-sky, verification tests rather than falsifiability tests. Additionally, they are prototypes and hence, TDD tests should (in theory) be thrown away and rewritten (sunk-cost fallacy).

Audits

How will you test the system?

Look at the tests, not the techniques.

James Bach - The Test Design Starting Line: Hypotheses - Keynote PeakIT004

Testing Certifications

Standards:

International software testing qualifications board (ISTQB):

In the exam:

ISO/IEC/IEEE 29119-4 Test Techniques

Split into three different high-level types:

Specification

Equivalence Class Partitioning (ECP)

Partition test conditions, usually inputs, into sets: equivalence partitions/classes. Be careful of sub-partitions.

Only one test per partition is required.

e.g. alphabetical characters, alphanumeric, ASCII, emoji, SQL injection.

e.g. square root function could have num >= 0, int <= 0, float <= 0 equivalence classes

Classification Tree Method

Grimm/Grochtmann, 1993:

e.g. DBMS:

Boundary Value Analysis

Test along the boundary:

Syntax Testing

Tests the language’s grammar by testing the syntax of all inputs in the input domain.

Requires a very large number of tests. Usually automated and may use a pre-processor.

Note that a correct syntax does not mean correct functionality.

Process:

Combinatorial Test Techniques

When there are several parameters/variables. TODO

Reduce the test space using other techniques:

Decision Table Testing

AKA cause-effect table testing

Software makes different decisions based on a variety of factors:

Decision table testing tests decision paths: different outputs triggered by the above conditions.

Decisions tables help to document complex logic and business rules. They have CONDITIONS (e.g. user logged in or not) and ACTIONS that are run when the conditions are met (that are run by the user and/or system).

Cause-Effect Graphs

AKA Ishikawa diagram, fish bone diagram.

Document dependencies.

Syntax:

Example

If the user clicking the ‘save’ button is an administrator or a moderator, then they are allowed to save. When the 'save” button is clicked, it should call the ‘save’ functionality.

If the user is not an admin or moderator, then the message in the troubleshooter/CLI should say so.

If the ‘save’ functionality is not hooked up to the ‘save’ button, then there should be a message about this when the button is clicked.

C1: the user is an admin C2: the user is a moderator C3: the save functionality is called

E1: the information is saved E2: the message ‘you need to be an authenticated user’ E3: the massage ‘the save functionality has not been called’

c1
   \    ----~--- e3
    \  /
 v ( > --------- e1
    /         ^(/
               /
c2 /      ____/
      ___/
c3 _/___________ e2

More complex diagrams should use fishbone diagrams.

State Transition Graphs
Scenario Testing

Scenarios are a sequence of interactions (between systems, users etc.).

Scenarios should be credible and replicate an end-user’s experience. They should be based off of a story/description.

Scenario tests test the end-to-end functionality and business flows, both blue-sky and error cases. However, scenario tests should not need to be exhaustive - these are expensive and heavily-documented tests.

Scenario tests also test usability from the user’s perspective, not just business requirements.

Random/Monkey Testing

Using random input to test; used when the time required to write and run the directed test is too long, too complex or impossible.

Heuristics could be used to generate tests, but care should be taken to ensure there is still sufficient randomness as to cover the specification.

There needs to be some sort of mechanism to determine when a test fails and the ability to be able to reproduce the failing test.

Monkey testing useful to prevent tunnel vision and when you cannot think laterally.

Structure-Based Techniques

Structure and data.

Statement Testing

AKA line/segment coverage.

Test checks/verifies each line of code and the flow of different paths in the program.

Conditions that are always false cannot be tested.

Similar to BVA except it is focused more on the paths rather than the input.

Branch/Decision Testing

Test each branch where decisions are made.

Branch coverage:

All branches are validated.

Data Flow Testing

Test for data flows, detects improper use of data in a program such as:

It creates a control flow graph and a data flow graph; the latter represents data dependencies between operations.

Static data flow testing analyzes source code without executing it, which dynamic data flow testing does the analysis during execution.

(e.g. data just passing though a class without being used directly by it?).

Experience-based Testing

Error guessing: get a experienced tester to think of situations that may break the program.

Error guessing: