Skip to content

Exercise 2: Input Space Partitioning & Control Flow Graph

In this exercise, you will practice model-based test design on a fork of Spring Petclinic REST. You will build an Input Domain Model (IDM) and a Control Flow Graph (CFG) for two methods, derive test requirements using coverage criteria, and connect the resulting test values and paths to the project's JUnit test suite.

Getting Started

Do the following steps before starting the exercise:

  1. Ensure you are enrolled in PMPL (SQA) course and have an account on GitLab CSUI. If you don't have an account, please notify the instructors as soon as possible.
  2. Set up the required tools on your local development machine:
  3. Git
  4. Java JDK version 17
  5. (optional) A text editor/IDE that supports Markdown and Java, e.g., Visual Studio Code or JetBrains IntelliJ
  6. Open the project page: Spring Petclinic REST.
  7. Fork the repository to your own namespace on GitLab CSUI, then clone your fork:
    1
    2
    git clone git@gitlab.cs.ui.ac.id:<your-namespace>/spring-petclinic-rest.git
    cd spring-petclinic-rest
    
  8. Ensure the main branch of your fork is csui:
    1
    2
    git status
    # On branch csui
    
  9. Create a working branch for this exercise:
    1
    git switch -c task/2-modeling
    

Task 1: Build the Input Domain Model (IDM)

You will build an IDM for the following methods:

  • updateVet in VetRestController
  • saveUser in UserServiceImpl

Steps for each method:

  1. Identify the inputs and their characteristics (interface-based and/or functionality-based). Define meaningful partitions (blocks) for each characteristic.
  2. Identify constraints among characteristics, if any (e.g., infeasible combinations, conditional dependencies). Use constraints to prune unfeasible test values.
  3. List the test requirements using Pair Wise Coverage (PWC).
  4. Derive concrete test values that satisfy the PWC requirements.
  5. Document the IDM in the report (tabular format is recommended; see template).

Task 2: Build the Control Flow Graph (CFG)

You will build a CFG for the following methods:

  • updateVet in VetRestController
  • saveUser in UserServiceImpl

Steps for each method:

  1. Create the CFG including entry/exit, nodes (basic blocks), and directed edges (control transfers). You may use any diagramming tool.
  2. List the test requirements using Edge-Pair Coverage (EPC).
  3. Derive test paths that satisfy the EPC requirements.
  4. Export and include the CFG diagram in the report.

Task 3: Validate Against the Existing JUnit Test Suite

For each method:

  1. Map at least one IDM-derived test value to an existing JUnit test case in the project. Explain the mapping briefly (max. 3 sentences).
  2. Map at least one CFG-derived test path to an existing JUnit test case. Explain briefly (max. 3 sentences).
  3. If no existing test satisfies a required value/path, add a new JUnit test method that does. Justify the addition (max. 3 sentences) and keep the test style consistent with the project.
  4. Commit and push your changes to your fork on GitLab CSUI.

Deliverables

At the end of this exercise, prepare the following artefacts in your fork:

  • A written report named EXERCISE_2_REPORT.md (or EXERCISE_2_REPORT.docx). The report must include for each chosen method:
    • The IDM and its constraints
    • The PWC test requirements and selected test values
    • The CFG, the EPC test requirements, and selected test paths
    • The mapping from test values/paths to JUnit tests (and justifications)
  • The CFG diagram files (e.g., screenshots or exports in PNG) referenced from the report
  • Updates to the JUnit test suite if you added new tests

Ensure the updated codebase and the written report is commited and pushed to your fork on GitLab CSUI.

The due date of this exercise is: Friday, 26 September 2025, 23:55 UTC+7. Submit the URL of your fork repository to the designated submission slot on SCELE. Please ensure any updates to the fork repository related to this exercise were made and pushed before the due date.

Generative AI Usage Policy

You may use generative AI tools for this exercise, but you must understand that you are trying to learn and practice the subject, not the AI itself. AI may produce incorrect results; review outputs critically.

If you do use generative AI, you must agree to the following:

Allowed Uses

  • Code generation (e.g., suggest test cases or refactorings)
  • Explanations (e.g., clarify partitioning decisions, coverage criteria)
  • Debugging help (e.g., interpret failing tests)

For every AI-assisted change, document it in the report under AI Assistance Log.

Prohibited Uses

  • Direct submission of AI-generated content without understanding or testing it
  • Bypassing learning by outsourcing the entire report or model construction

Report Template

You can use the following Markdown template as a starting point:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Exercise 2 Report

- **Name:** <NAME>
- **NPM:** <NPM>

## IDM for Method 1 (updateVet)

### Input Domain Model
| Characteristic | b1  | b2  | ... |
|----------------|-----|-----|-----|
| A              | A1  | A2  |     |
| B              | B1  | B2  |     |

### Constraints
- C1: <describe>

### Test Requirements (Base Choice Coverage)
- Base choices: {A:=A1, B:=B1, ...}
- Requirements: <enumerate>

### Selected Test Values and Example I/O
| Test Value | Example Input | Expected Output |
|------------|----------------|-----------------|
| A1B1...    | ...            | ...             |

## CFG for Method 1 (updateVet)

### Diagram
> Include image here using Markdown syntax.
> Do not forget to include the image files into the codebase as well!

### Test Requirements (Edge-Pair Coverage)
- <enumerate edge pairs>

### Selected Test Paths
- p1: <nodes/edges>

## Mapping to JUnit Test Suite (Method 1)
- IDM value A1B1... -> `SomeTest#testX()` (reason: ...)
- CFG path p1 -> `SomeTest#testY()` (reason: ...)

---

## IDM/CFG for Method 2 (saveUser)
> Repeat the same structure as Method 1

## AI Assistance Log
| Task | Prompt Used | Summary of AI Response | Your Evaluation | Final Implementation |
|------|-------------|------------------------|-----------------|----------------------|

References

  • Paul Ammann & Jeff Offutt, Ch. 6 Input Space Partitioning (slides): https://cs.gmu.edu/~offutt/softwaretest/powerpoint/Ch06-ISP.pptx
  • MIT 6.005 Software Construction, Reading 3: Testing: https://ocw.mit.edu/ans7870/6/6.005/s16/classes/03-testing/index.html

Generative AI Use Disclosure

GitHub Copilot with GPT-5 is used to draft and proofread this document.


Last update: 2025-10-02 02:03:52
Created: 2025-09-17 13:10:05