A requirement for an online shop says that a signed-in customer who changes the order number in a request must not be shown another customer's order, and the attempt must be recorded.
Misuse cases, test coverage and interface testing
Software is tested against what it should do, and it should also be tested against what it must never allow. Misuse cases describe the attacks a system must refuse. Coverage measures how much of the program the tests reached, and interface testing checks where a system meets people, networks, programs and devices. No background is assumed. A security professional uses them to judge whether 'all tests passed' means anything.
By the end of this unit you will be able to:
- Tell apart a use case, a misuse case and an abuse case, and positive and negative testing
- Calculate test coverage as a percentage
- Tell apart statement, branch, condition, multiple condition, function, loop and path coverage
- Explain what is tested at user, network, programming and physical interfaces
- Put in order unit, integration, system and acceptance testing, and explain regression testing
All 120 tests passed
An illustrative example
A dental practice buys a new online booking system. Before it goes live, the supplier sends a one-line report: all 120 tests passed.
The practice manager asks two questions. Did any test try to book, view or cancel an appointment in another patient's name? And did the tests ever reach the part of the program that handles cancellations, or only the part that makes bookings? The supplier promises to find out.
Why does 'all tests passed' not answer either of the manager's questions?
Use cases say what should happen, misuse cases what must not
Software requirements are often written as . A use case describes one exchange between a user and a system that ends in a useful result, such as a patient booking an appointment.
A misuse case is the opposite: a sequence of actions the system must not allow, because it would cause harm to the organisation or someone else. It has its own actor, the misuser, who starts it. Researchers Guttorm Sindre and Andreas Opdahl proposed so that security requirements could be written in the same form as ordinary ones. An abuse case, in OWASP's terms, is a way of using a feature that its builder did not expect. The two words are often used for the same idea.
| Kind | Booking example | Test it produces |
|---|---|---|
| Use case | A patient books a free slot in their own name | : the booking succeeds |
| Misuse case | A patient changes the patient number in the request to see another patient's bookings | : the request is refused and recorded |
| Misuse case | A script books every free slot for a month | Negative test: bookings are limited and the account flagged |
Misuse case testing turns each misuse case into a test that checks the system refuses it. This is negative testing: giving the system wrong, hostile or unexpected actions and checking that it fails safely. Positive testing checks that correct use gives the correct result. Misuse cases come naturally from , which lists who might attack a system and how.
Test coverage: how much was actually tested
A count of passed tests says nothing about what the tests missed. Coverage analysis measures how much of something the tests actually exercised, as a percentage. The something is chosen first: the program's statements, its branches, its requirements or its use cases.
Test coverage
Coverage = (items exercised by the tests ÷ total items) × 100%
- Items exercised
- How many of the chosen items, such as statements or use cases, the tests reached at least once.
- Total items
- How many of those items exist.
The booking program has 600 statements and the tests ran 450 of them. Coverage = 450 ÷ 600 × 100% = 75% statement coverage.
A statement is one instruction in the program. A branch is one of the routes a program can take at a decision, such as the yes route and the no route of 'is the slot free?'. A condition is one true-or-false test inside a decision.
| Criterion | What every test run together must reach |
|---|---|
| Function coverage | Every function, a named block of code, called at least once |
| Statement coverage | Every statement run at least once |
| Branch or decision coverage | Every decision taken both ways, true and false |
| Condition coverage | Every condition inside a decision both true and false |
| Multiple condition coverage | Every combination of conditions in each decision: 4 tests for 2 conditions, 8 for 3 |
| Loop coverage | Every repeating block run zero times, once and more than once |
| Path coverage | Every possible route from the start of the program to its end |
Every statement run is not every branch taken
Read this figure as text
A statement is one instruction; a branch is one route a program can take at a decision. The booking program's decision, is the slot free, has an if with no else, so its no branch holds no statement of its own.
- Test 1 asks the booking program for a slot that is free. It is the only test run.
- At the decision, the slot is free, so the test takes the yes branch, which records the booking.
- The program then sends a confirmation. Both statements have run.
- The no branch, for a slot already taken, goes straight to sending the confirmation with no statement of its own. Test 1 never takes it.
- Every statement ran in test 1, so statement coverage is 100%.
- Only one of the two branches was taken, so branch coverage is 50%. A second test with the slot already taken is needed for 100%.
Full can leave branches untested. Where the no route of 'is the slot free?' has no instructions of its own, a test that always finds the slot free runs every statement and never takes the no route. NIST recommends at least 80% statement coverage for developers, and warns that very high coverage still guarantees little. Coverage shows where tests have not been. It does not show that the tests checked the right things.
Interface testing: where a system meets something else
An interface is a point where a system exchanges information with something outside itself. Defects gather at interfaces, because each side assumes the other checks things. Interface testing checks that each interface accepts only what it should and handles the rest safely.
| Interface | What it is | What is tested |
|---|---|---|
| User interface | The screens, forms and buttons people use | Hidden or greyed-out options cannot be forced, and every field rejects unexpected input |
| Network interface | The connection through which a system sends and receives traffic, on its ports | Only the intended services answer, traffic is , and malformed traffic is handled |
| Application programming interface (API) | The defined way other programs ask the system for data or actions | Every request is authenticated and authorised, one user cannot fetch another's records, and limits apply |
| Physical interface | Ports and devices on the hardware, such as USB sockets, card readers and maintenance ports | Unused ports are disabled or locked, and maintenance ports need authority |
An API needs testing on its own. A booking app's screen may hide other patients' records, while the API behind it hands them to anyone who asks directly.
Unit, integration, system and acceptance tests
Software is tested in levels, from the smallest part to the whole.
- Unit testing, also called component testing: each small part is tested on its own, usually by the programmer who wrote it.
- Integration testing: parts are joined and tested together, to find defects in the interfaces between them.
- System testing: the complete system is tested against its written requirements, including its security requirements.
- Acceptance testing: the customer, or the users, test the system against their needs and decide whether to accept it. When intended users do it in a real or realistic setting it is user acceptance testing.
Regression testing runs at any level after a change. Earlier tests are run again to check that the change has not broken something that used to work. Every fix to a security flaw should add a test that would catch the flaw if it ever came back.
Common misconception
“Once users have accepted a system, its security has been tested.”
Acceptance testing checks that the system meets the users' needs. Users try normal tasks. Security needs negative tests, misuse cases and interface tests, which users rarely think to run.
Worked example: Two coverage figures for the booking system
The supplier's tool reports that the 120 tests ran 540 of the program's 600 statements. The program contains 50 decisions, so 100 branches. The tests took 70 of those branches.
- Statement coverage = 540 ÷ 600 × 100% = 90%.
- Branch coverage = 70 ÷ 100 × 100% = 70%.
- So 30 routes through the program's decisions were never taken by any test.
- The manager asks which of the 30 missed branches are in the cancellation code, and asks for negative tests built from the misuse case of acting as another patient.
A 90% figure looked reassuring. Branch coverage shows that nearly a third of the decision routes were never tested, and neither figure says whether any test tried to misuse the system.
A question, worked through
A payroll firm's tests reach 100% statement coverage of a new payment program. After release, a payment is sent twice when a bank's reply is late. The code that should stop a second payment has an 'if' with no 'else': when the reply is late, the program skips the check. No test ever made the reply late.
Which coverage criterion, if required, would have forced a test of this situation?
Decide on your answer, then open the reasoning
- The defect lies on the false route of a decision that has no instructions of its own. The question asks which measure requires that route to be tested.
- Rule out c: statement coverage was already 100%. A route with no statements on it adds nothing to that figure.
- Rule out d: regression testing repeats earlier tests after a change. None of the earlier tests made the reply late.
- Between a and b: function coverage only needs the payment function to be called once. Branch coverage needs every decision taken both ways, which forces a test where the check is false.
Answer: B. Branch coverage of the payment program
Choosing between good answers
- A question asks how to test that a system refuses something an attacker would try
- choose misuse case testing, which is negative testing. Use cases alone test only intended behaviour.
- A question gives counts of items tested and items in total
- coverage is exercised divided by total, times 100.
- A question says statement coverage is complete yet a decision went wrong
- the missing measure is branch coverage. Where one part of a combined test was never varied, it is condition coverage.
- A question asks which test finds defects where two components connect
- choose integration testing or interface testing.
Check your understanding
5 questions on this unit, easiest first. Confirm an answer to see the reasoning for it, then the right answer, the other options and the rule to reuse. Your answers are kept in this browser and feed readiness and review.
These questions are drafts that no named reviewer has approved yet.
Question 1 of 5
What to remember
- A use case describes intended use. A misuse case describes a harmful action by a misuser that the system must refuse, and becomes a negative test.
- Coverage = items exercised ÷ total items × 100%. It shows what the tests never reached, not whether they checked the right things.
- Branch coverage needs every decision taken both ways, and is stronger than statement coverage. Multiple condition coverage needs every combination of conditions.
- Interface testing checks user interfaces, network interfaces, APIs and physical interfaces. Each must refuse what it should not accept.
- Unit, integration, system and acceptance testing run from smallest part to whole. Regression testing repeats earlier tests after any change.
Say it from memory
What is misuse case testing, and how does it differ from testing use cases?
A misuse case describes actions a misuser could take that the system must not allow. Misuse case testing turns each one into a negative test that checks the system refuses the action and fails safely. Use case tests are positive: they check that intended use works.
How is test coverage calculated, and what do statement, branch and multiple condition coverage each require?
Coverage = items exercised ÷ total items × 100%. Statement coverage needs every statement run once. Branch coverage needs every decision taken both true and false. Multiple condition coverage needs every combination of the conditions in each decision. Function, loop and path coverage count functions called, loops run zero, once and many times, and complete routes.
What is interface testing, and what is tested at the user, network and programming interfaces?
Testing the points where a system exchanges information with something else, to check each accepts only what it should. User interface: hidden options cannot be forced and fields reject odd input. Network interface: only intended services answer and traffic is protected. API: every request is authenticated and authorised. Physical ports are tested too.
Give the four levels of software testing in order, and say what regression testing is.
Unit testing of each small part, integration testing of joined parts and their interfaces, system testing of the complete system against its written requirements, then acceptance testing by the customer or users. Regression testing runs earlier tests again after a change, at any level, to check nothing that used to work is broken.
Sources
- Standard Glossary of Terms used in Software Testing, Version 3.2: Foundation Terms, International Software Testing Qualifications Board (ISTQB)Use case, coverage as a percentage of items exercised, statement coverage, decision coverage, path, component or unit testing, integration testing exposing defects in interfaces, system testing against requirements, acceptance and user acceptance testing, and regression testing.
- Capturing Security Requirements through Misuse Cases, Guttorm Sindre (Norwegian University of Science and Technology) and Andreas L. Opdahl (University of Bergen)A misuse case as the inverse of a use case, a sequence of actions resulting in loss that the system should not allow, and the mis-actor who initiates it.
- Abuse Case Cheat Sheet, OWASP Cheat Sheet SeriesAn abuse case as a way to use a feature that was not expected by the implementer, treated together with misuse cases, and abuse cases as a source of security requirements and tests.
- A Practical Tutorial on Modified Condition/Decision Coverage (NASA/TM-2001-210876), NASA Langley Research Center (Hayhurst, Veerhusen, Chilenski and Rierson)Statement, decision, condition and multiple condition coverage, their order from weakest to strongest, and multiple condition coverage needing every combination of inputs to a decision.
- SP 800-53 Rev. 5, Security and Privacy Controls for Information Systems and Organizations, NISTCode coverage analysis by measures such as the percentage of subroutines tested or of program statements called during testing.
- NIST IR 8397: Guidelines on Minimum Standards for Developer Verification of Software, National Institute of Standards and TechnologyA minimum of 80% statement coverage, statement coverage as the weakest widely used criterion, branch coverage requiring every branch to be taken, and very high coverage guaranteeing little.
- Loop unrolling: formal definition and application to testing, Li Huang, Bertrand Meyer and Reto Weber, Constructor Institute of Technology (arXiv 2502.15535)Branch coverage considering only a loop that runs its body once or not at all, and missing two or more iterations.
- NIST SP 800-115: Technical Guide to Information Security Testing and Assessment, NISTCode analysis cannot detect defects in interfaces between components, which black box testing of interactions must address.