1 / 57

COIT20258

Software Engineering

Week 6: Software Testing

Understanding testing methodologies, strategies, and best practices

Today's Topics

Program Testing

Two Testing Goals

Validation Testing

To demonstrate to the developer & the system customer that the software meets its requirements

A successful test shows that the system operates as intended

Defect Testing

To discover faults or defects in the software where its behavior is incorrect or not in conformance with its specification

A successful test is a test that makes the system perform incorrectly & so exposes a defect

An Input-Output Model of Program Testing

Input test data (Ie)

Inputs causing anomalous behaviour

System

Output test results (Oe)

Outputs which reveal the presence of defects

Validation & Verification (V&V)

Validation

"Are we building the right product?"

The software should do what the user really requires; related to validation testing

Verification

"Are we building the product right?"

The software should conform to its specification; related to defect testing

V&V Confidence

Aim of V&V is to establish confidence that the system is "fit for purpose"

Depends on system's purpose, user expectations & marketing environment:

  • Software purpose: The level of confidence depends on how critical the software is to an organization
  • User expectations: Users may have low expectations of certain kinds of software
  • Marketing environment: Getting a product to market early may be more important than finding defects

Inspections & Testing

Software Inspections

Concerned with analysis of the static system representation to discover problems (static verification)

May be supplemented by tool-based document & code analysis

Software Testing

Concerned with exercising & observing product behaviour (dynamic verification)

The system is executed with test data & its operational behaviour is observed

Software Inspection

Inspections & Testing

  • Inspections & testing are complementary
  • Both should be used during the V&V process
  • Inspections can check conformance with a specification but not conformance with the customer's real requirements
  • Inspections cannot check non-functional characteristics such as performance & usability

A Model of the Software Testing Process

Design test cases

Create test scenarios

Prepare test data

Set up test inputs

Run program with test data

Execute tests

Compare results to test cases

Analyze outputs

Generate test reports

Document findings

Stages of Testing

Development Testing - discover bugs & defects during development
Release Testing - separate team tests complete version before release
User Testing - users test system in their own environment

Development Testing

Development testing includes all testing activities carried out by the team developing the system:

Unit Testing

Individual program units or object classes are tested. Focus on testing functionality of objects or methods.

Component Testing

Several individual units are integrated to create composite components. Focus on testing component interfaces.

System Testing

Some or all components in a system are integrated. Focus on testing component interactions.

Unit Testing

Object Class Testing

Complete test coverage of a class involves:

Challenge: Inheritance makes it more difficult to design object class tests as the information to be tested is not localized

The Weather Station Object Interface

WeatherStation

  • identifier
  • reportWeather()
  • reportStatus()
  • powerSave(instruments)
  • remoteControl(commands)
  • reconfigure(commands)
  • restart(instruments)
  • shutdown(instruments)

Weather Station Testing

Automated Testing

Benefit: Automation enables continuous testing and reduces human error in test execution

Automated Test Components

Setup Part

Initialize the system with the test case, namely the inputs & expected outputs

Call Part

Call the object or method to be tested

Assertion Part

Compare the result of the call with the expected result. If assertion evaluates to true, test successful; if false, test failed

Choosing Unit Test Cases

The test cases should show that, when used as expected, the component works correctly. If there are defects, these should be revealed by test cases.

Normal Operation Tests

Should reflect normal operation of a program & should show that the component works as expected

Abnormal Input Tests

Should use abnormal inputs to check that these are properly processed & do not crash the component

Testing Strategies

Partition Testing

Identify groups of inputs that have common characteristics & should be processed in the same way

You should choose tests from within each of these groups

Guideline-based Testing

Use testing guidelines to choose test cases

These guidelines reflect previous experience of the kinds of errors that programmers often make

Partition Testing

Equivalence Partitioning

Possible Inputs

Input equivalence partitions

System

Possible Outputs

Output partitions

Correct outputs

Equivalence Partitions Examples

Input Values

Less than 10000: 9999

Between 10000 and 99999: 10000, 50000, 99999

More than 99999: 100000

Number of Input Values

Less than 4: 3

Between 4 and 10: 4, 7, 10

More than 10: 11

Testing Guidelines (Sequences)

General Testing Guidelines

Component Testing

Interface Testing

The objective is to detect faults due to interface errors or invalid assumptions about interfaces

Parameter interfaces

Data passed from one method or procedure to another

Shared memory interfaces

Block of memory is shared between procedures or functions

Procedural interfaces

Sub-system encapsulates a set of procedures to be called by other sub-systems

Message passing interfaces

Sub-systems request services from other sub-systems

Interface Errors

Interface misuse

A calling component calls another component & makes an error in its use of its interface e.g., parameters in the wrong order

Interface misunderstanding

A calling component embeds assumptions about the behaviour of the called component which are incorrect

Timing errors

The called & the calling component operate at different speeds & out-of-date information is accessed

Interface Testing Guidelines

System Testing

Use-Case Testing

Testing Policies

Exhaustive system testing is impossible so testing policies which define the required system test coverage may be developed

Examples of testing policies:

  • All system functions that are accessed through menus should be tested
  • Combinations of functions (e.g., text formatting) that are accessed through the same menu must be tested
  • Where user input is provided, all functions must be tested with both correct & incorrect input

Test-Driven Development

TDD Process

Identify new functionality

Define what to build

Write test

Create automated test

Run test

Execute (should fail)

Implement functionality

Write code to pass test

Refactor

Improve code quality

TDD Process Activities

  1. Start by identifying the increment of functionality that is required. This should normally be small & implementable in a few lines of code
  2. Write a test for this functionality & implement this as an automated test
  3. Run the test, along with all other tests that have been implemented. Initially, you have not implemented the functionality so the new test will fail
  4. Implement the functionality & re-run the test
  5. Once all tests run successfully, you move on to implementing the next chunk of functionality

Benefits of TDD

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 & modified

System Documentation

The tests themselves are a form of documentation that describe what the code should be doing

Regression Testing

Release Testing

Release Testing & System Testing

Release testing is a form of system testing

Key Difference 1

A separate team that has not been involved in the system development, should be responsible for release testing

Key Difference 2

System testing by the development team should focus on discovering bugs in the system (defect testing). The objective of release testing is to check that the system meets its requirements & is good enough for external use (validation testing)

Requirements-Based Testing

Requirements-based testing involves examining each requirement & developing a test or tests for it

Mentcare system requirements example:

  • If a patient is known to be allergic to any particular medication, then prescription of that medication shall result in a warning message being issued to the system user
  • If a prescriber chooses to ignore an allergy warning, they shall provide a reason why this has been ignored

Requirements Tests

A Usage Scenario for the Mentcare System

George is a nurse who specializes in mental healthcare. One of his responsibilities is to visit patients at home to check that their treatment is effective & that they are not suffering from medication side effects.

On a day for home visits, George logs into the Mentcare system & uses it to print his schedule of home visits for that day, along with summary information about the patients to be visited. He requests that the records for these patients be downloaded to his laptop. He is prompted for his key phrase to encrypt the records on the laptop.

One of the patients that he visits is Jim, who is being treated with medication for depression. Jim feels that the medication is helping him but believes that it has the side effect of keeping him awake at night. George looks up Jim's record & is prompted for his key phrase to decrypt the record.

Features Tested by Scenario Tests

Performance Testing

User Testing

Types of User Testing

Alpha Testing

Users of the software work with the development team to test the software at the developer's site

Beta Testing

A release of the software is made available to users to allow them to experiment & to raise problems that they discover with the system developers

Acceptance Testing

Customers test a system to decide whether or not it is ready to be accepted from the system developers & deployed in the customer environment. Primarily for custom systems

The Acceptance Testing Process

Define acceptance criteria

Establish standards

Plan acceptance testing

Create test strategy

Derive acceptance tests

Design specific tests

Run acceptance tests

Execute test cases

Negotiate test results

Review findings

Accept or reject system

Make final decision

Stages of the Acceptance Testing

  1. Define acceptance criteria
  2. Plan acceptance testing
  3. Derive acceptance tests
  4. Run acceptance tests
  5. Negotiate test results
  6. Reject/accept system

Agile Methods & Acceptance Testing

Key Points

Key Points (Continued)

Summary

Today we covered:

  • The fundamentals of software testing and V&V
  • Development testing strategies (Unit, Component, System)
  • Test-driven development approach
  • Release testing and requirements validation
  • User testing methods including acceptance testing

Remember: Testing shows the presence of bugs, not their absence!

Questions & Discussion

Think about:

  • How would you apply TDD to your current projects?
  • What testing strategies are most relevant to your domain?
  • How can you balance testing thoroughness with development speed?
  • What role should users play in your testing process?

Next Week

We'll continue our exploration of software engineering by examining:

Preparation: Review today's testing concepts and think about how they apply to long-term software maintenance

Additional Resources

Testing Frameworks

JUnit (Java), pytest (Python), Jest (JavaScript), NUnit (.NET)

Books

"The Art of Software Testing" by Myers, Sandler & Badgett

Online Resources

Software Testing Help, Ministry of Testing community

Tools

Selenium (web testing), Postman (API testing), LoadRunner (performance)

Thank You

Questions?

COIT20258 - Software Engineering
Week 6: Software Testing