Instruction session · Thursday, December 3, 2026 · 25 minutes of exposition, then each student works alone · in-class graded activity
Which tests does a DataApp need? The quality attributes that the partner depends on answer the question. In this session each student derives them with the ATAM: a utility tree, quality attribute scenarios in six parts, test cases traced to each scenario, and a pytest suite whose results return to the tree as risks and tradeoffs.
Project ritual
Each group reports the progress of its deliverables, the work planned for this session and the blockers that require a decision.
The professor presents the method in 25 minutes, with the reference applied to the package of Lesson 7. From 0:40 on, each student applies the six steps of the method to the DataApp of the group and then puts its tests in a pipeline of git.inteli.edu.br, with the CREATE prompts of the lab and a coding agent, while the professor circulates.
lab/lesson-9/tcg_dataapp/: the same package of Lesson 7 with the six documents of the method, 29 tests, the two runs recorded and .gitlab-ci.yml. The lab of the session replays the seven steps in the browser, with the pipelines recorded on 12/11/2026.A DataApp runs every day without a person. Each claim that someone checked once by reading a result (the grain holds, a rerun duplicates nothing, a frozen report never changes) must become code that checks it at every change, or it stops being true without anyone noticing.
The nine tests of Lesson 7 run in two seconds at every change; a change that breaks the idempotent load fails before it reaches the main branch.
test_a_month_with_two_captures_freezes_only_the_last is the semi-additive rule of Lesson 6, written so that a machine can check it.
The fake source of the tests exists because the ETL layer receives its client as a parameter; a layer that opened the network by itself could not be tested offline.
The test pyramid orders the tests by the size of what they exercise. The lower the level, the faster the test and the more precisely a failure points to its cause; the higher the level, the closer the test is to what the user sees.
| Level | Exercises | In the reference package | Time |
|---|---|---|---|
| unit | one function, without I/O | order() rejects a cycle; freeze_month rejects a month that is not YYYY-MM | milliseconds |
| integration | one layer with a real DuckDB in memory | a batch loaded twice is replaced; the gates of check_gold | tens of ms |
| contract | the shape of an output that others read | the Parquet marts against docs/contracts/marts.json | tenths of a second |
| end to end | the whole pipeline with a fake source | a full run, a rerun, a source down, a renamed field | tenths of a second |
| performance | a measure of time under a given volume | 100,000 synthetic prices from build_gold to write_report | about 1.3 s |
Each test prepares a situation, performs one action and checks its outcome. pytest finds the functions named test_*, injects the fixtures they ask for and reports each failure with the values that differed.
@pytest.mark.scenario("S04") # marker
def test_s04_renamed_price_field_stops_the_run(settings): # fixture
"""TC04.1 a renamed price field stops the run"""
prices = copy.deepcopy(PRICES) # Arrange
for rows in prices["2026-09-01"].values():
for r in rows:
r["market_price"] = r.pop("marketPrice")
ctx = pipeline.run(settings, # Act
client=FakeClient(prices=prices))
assert "check_quality" in ctx.results["_failed"] # Assert| Resource | Use |
|---|---|
| fixture | the environment of the scenario: settings with a temporary folder; no_network, applied to every test |
parametrize | the same test over several stimuli |
| marker | scenario("S04") ties the test to its scenario |
monkeypatch | replaces the clock or an environment variable |
--junitxml | the report that a CI server reads |
The Architecture Tradeoff Analysis Method, of the Software Engineering Institute, evaluates an architecture against the quality attributes that its business drivers require. This session condenses it into six steps, each one producing a file of the repository.
The root is the utility of the system. Each leaf is a concrete scenario rated twice, from H to L: how much the business drivers depend on it, and how hard it is for the architecture to achieve it. Leaves rated (H,H) and (H,M) are analysed and tested first.
Utility ├── Correctness │ ├── Idempotent runs ................ S01 (H,M) │ ├── No wrong number published ...... S02 (H,M) │ ├── Every price reaches the model .. S03 (H,M) │ ├── Schema drift of the source ..... S04 (H,H) │ └── Semi-additive measure .......... S05 (H,H) ├── Reliability │ ├── Transient failure of the source S06 (H,L) │ └── Source down for the whole run .. S07 (H,M) ├── Auditability ....................... S08 (H,L) S09 (M,L) ├── Interoperability · contract ........ S10 (M,L) ├── Timeliness · stale data ............ S11 (M,L) ├── Performance · budget ............... S12 (M,M) ├── Testability · offline .............. S13 (M,L) └── Modifiability · configuration ...... S14 (L,L)
| Driver | Need |
|---|---|
| BD1 | a wrong number costs more than a late one |
| BD2 | the frozen report is cited after the month |
| BD3 | the source has no service level |
| BD4 | runs daily, unattended, on modest hardware |
| BD5 | the model changes every sprint |
A leaf of the tree is still a sentence. The scenario makes it precise: who causes what, in which part of the system and in which state, what the system does, and how that response is measured.
tcgcsv.com
is down during the whole run
pipeline.py and cli.py
unattended daily run after a successful run
the run fails naming the task, skips its dependents and leaves what was published
exit code 1; no new row in db_ingestion; out/report.md byte-identical
Every test traces to one scenario, and every scenario to its tests. A marker makes the link part of the code, so the suite itself prints which scenarios pass, fail or have no test.
============== ATAM traceability ============== S01 (H,M) Correctness · Idempotent runs 2/2 PASS S02 (H,M) Correctness · No wrong number published 2/2 PASS S03 (H,M) Correctness · Every price reaches the model 2/2 PASS S04 (H,H) Correctness · Schema drift of the source 2/2 PASS S05 (H,H) Correctness · Semi-additive measure 1/1 PASS S06 (H,L) Reliability · Transient failure of the source 1/1 PASS S07 (H,M) Reliability · Source down for the whole run 2/2 PASS ... S14 (L,L) Modifiability · Sets by configuration 1/1 PASS suite time 8.78 s 29 passed in 8.77s
| Piece | Role |
|---|---|
docs/scenarios.toml | the single source of the scenarios |
@pytest.mark.scenario("S07") | the link from the test to the scenario |
docstring TC07.1 … | the id of the test case |
plugin in conftest.py | refuses an unknown id, prints the table, writes out/traceability.json |
pytest --scenario S07 | runs one scenario |
tools/traceability.py | the utility tree with the results |
The ATAM does not end in a list of passed tests. Each result is read back into the tree and classified, so that the next decision of the team is based on the risks it found and on the tradeoffs it accepted.
The inner join of gold.fact_price drops a price whose product is not in the catalogue, and no check notices (S03).
Reading the JSON by field name makes a new field of the source change no number (S04, TC04.2).
The timestamp of noon UTC decides what is the same batch; another hour breaks the idempotency of S01.
A stricter quality gate publishes fewer wrong numbers and causes more failed runs: correctness against availability (S02 to S04).
The scenarios were written and tested against the package of Lesson 7 as it was, without any fix. Three scenarios failed, and each failure named a risk that the nine tests of Lesson 7 did not reach.
| Scenario | Result on 0.1.0 | What the failure showed | Change in 0.3.0 |
|---|---|---|---|
| S03 (H,M) every price reaches the model | FAIL 0/2 | a price without product disappears in the join; the check fact_without_set could never fail | landing and fact compared per capture; above 1 % the run stops |
| S04 (H,H) schema drift | FAIL 1/2 | a renamed marketPrice publishes a report without that capture, and the run ends OK | more than 10 % null prices in a capture stops the run |
| S11 (M,L) stale data | FAIL 0/2 | nothing reports the age of the last capture | tcg-dataapp freshness, exit code 1 above 2 days |
build_gold to write_report; budget of S12: 10 sFrom this point each student works alone, on the DataApp packaged in Lesson 7, with the seven prompts of the lab and a coding agent. The next seven slides hold the prompts; each step produces a file of the repository and ends with a condition to check before moving on.
pip install -e '.[dev]' and pytestlab/lesson-9/tcg_dataapp/ shows the form, not the contentgraded-activity/student-nameStep 01 · 0:40 · Drivers · alone
What does the partner need from the DataApp, and which qualities follow from it? The answer comes from the code and the documents of the partner, and each attribute must cite the driver that justifies it.
docs/business_drivers.md: four to six drivers (BD1, BD2…) and the quality attributes, each with its meaning for this DataApp.
[C] Character
You are a software architect who runs the ATAM (Architecture Tradeoff
Analysis Method) on a data application. The application is the DataApp of
my group, packaged in Lesson 7 in three layers (views, processors, etls),
in the folder of this repository.
[R] Request
1. Read the README, pyproject.toml, the pipeline and the gold layer of the
package, and summarise in five lines what the DataApp does, for whom,
from which source and how often it runs.
2. Write docs/business_drivers.md with four to six business drivers
(codes BD1, BD2, ...). Each driver states a need of the partner or of
the users and its consequence for the architecture.
3. In the same file, list the quality attributes that follow from the
drivers (correctness, reliability, auditability, interoperability,
timeliness, performance, testability, modifiability, security...),
each with one sentence on what it means for THIS DataApp and the codes
of the drivers that justify it.
[E] Example
| BD3 | The source is a free public mirror without a service level, which
can fail, lag or change its fields without notice. | Failures of the
source are expected events, handled by retries, gates and checks of
freshness. |
[A] Adjustments
- Use what is in the code and in the partner documents; do not invent a
requirement. When a driver is a hypothesis, write "(hypothesis, to
confirm with the partner)".
- A quality attribute without a driver is removed.
- The reference of the professor is lab/lesson-9/tcg_dataapp/docs/
business_drivers.md: use its form, not its content.
[T] Type of output
The file docs/business_drivers.md and the summary of the DataApp.
[E] Extras
Show the plan before writing. Record this prompt in docs/prompts.md.
Stop at the end.
Step 02 · 0:48 · Utility tree · alone
The attributes are refined until each leaf names a situation that can happen to this DataApp. The two letters of each leaf decide the order of the rest of the session.
docs/utility_tree.md and docs/scenarios.toml with ten to fifteen leaves, each with id, attribute, refinement, importance and difficulty.
[C] Character
You are the same architect. The business drivers and the quality
attributes are in docs/business_drivers.md.
[R] Request
1. Build the utility tree in docs/utility_tree.md: the root is Utility,
the first level the quality attributes, the second their refinements,
and each leaf one concrete scenario in one line, with an id (S01,
S02, ...).
2. Rate each leaf with two letters, (importance, difficulty), each H, M
or L: importance for the business drivers, difficulty for the
architecture to achieve it. Justify each H in one sentence.
3. Give the order of analysis: (H,H) first, then (H,M), (M,H), and so on.
4. Create docs/scenarios.toml with one [[scenario]] per leaf, filling id,
attribute, refinement, importance, difficulty and drivers; the six
parts stay empty until step 03.
[E] Example
Utility
├── Correctness
│ ├── Idempotent runs ................ S01 (H,M)
│ └── Schema drift of the source ..... S04 (H,H)
[A] Adjustments
- Ten to fifteen leaves; at least one leaf per attribute of step 01.
- A leaf names a situation that can happen to this DataApp ("the source
renames a field"), never a wish ("the system is robust").
- Use lab/lesson-9/tcg_dataapp/docs/scenarios.toml as the format of the
file.
[T] Type of output
docs/utility_tree.md, docs/scenarios.toml and the order of analysis.
[E] Extras
Show the tree before writing the files. Record this prompt in
docs/prompts.md. Stop at the end.
Step 03 · 0:55 · Scenarios · alone
The leaves rated (H,H), (H,M) and (M,H) become scenarios first. The response measure is the part that matters most: it is what the test of step 05 will assert.
the six parts of each scenario in docs/scenarios.toml, and docs/scenarios.md with one table per scenario.
[C] Character
You are the same architect. The utility tree and the order of analysis are
in docs/utility_tree.md and docs/scenarios.toml.
[R] Request
For every leaf rated (H,H), (H,M) or (M,H), and then for as many of the
others as time allows, write the quality attribute scenario in six parts
in docs/scenarios.toml:
- source: who or what generates the stimulus;
- stimulus: the event that reaches the system;
- artifact: the part of the DataApp that receives it (a file, a table,
a task);
- environment: the state of the system when it happens;
- response: what the DataApp must do;
- measure: how the response is measured, with a number or a
verifiable condition.
Then generate docs/scenarios.md, with one table of six rows per scenario.
[E] Example
source = "tcgcsv.com"
stimulus = "is down during the whole run"
artifact = "pipeline.py and cli.py"
environment = "unattended daily run after a successful run"
response = "the run fails naming the task, skips its dependents and leaves what was published"
measure = "exit code 1; no new row in db_ingestion; out/report.md byte-identical"
[A] Adjustments
- The measure must be checkable by a test: "fast" or "reliable" is not a
measure; "less than 10 s on 100,000 rows" is.
- When a number of the measure comes from the real data (a share of
nulls, a time), measure it on the real data first and write the value
measured next to the limit.
- Keep the six parts short: one line each.
[T] Type of output
docs/scenarios.toml filled, docs/scenarios.md, and the list of the
scenarios that are still empty.
[E] Extras
Show the scenarios before writing. Record this prompt in docs/prompts.md.
Stop at the end.
Step 04 · 1:10 · Test cases · alone
A test case turns the stimulus into data that a test can produce, the environment into a fixture and the measure into assertions. Each case traces to exactly one scenario.
docs/test_cases.md (case, scenario, what it checks, test function, level), the field cases of the TOML and the contracts in docs/contracts/.
[C] Character
You are a test engineer who derives test cases from ATAM scenarios. The
scenarios are in docs/scenarios.toml.
[R] Request
1. For each scenario with six parts, derive one to three test cases
(TC01.1, TC01.2, ...). A test case fixes the stimulus as data the test
can produce, the environment as a fixture, and the measure as
assertions. Add the list to the field cases of the scenario.
2. Write docs/test_cases.md: test case, scenario, what it checks, and the
name of the test function that will implement it.
3. Say which level each test case is: unit (one function), integration
(one layer with a real DuckDB) or end to end (the whole pipeline with
a fake source).
4. When the measure is a contract (names and types of an output),
write the contract as a file in docs/contracts/.
[E] Example
| TC04.1 | S04 | a renamed price field stops the run |
tests/scenarios/test_correctness.py::test_s04_renamed_price_field_stops_the_run |
[A] Adjustments
- Every test case traces to exactly one scenario; a test case without a
scenario is not written.
- No test case calls the network: the source is a fake client, as in
tests/conftest.py of the reference package.
- Do not write the tests yet.
[T] Type of output
docs/test_cases.md, the field cases of docs/scenarios.toml and the
contracts, if any.
[E] Extras
Show the table before writing. Record this prompt in docs/prompts.md.
Stop at the end.
Step 05 · 1:20 · Tests · alone
The suite is written in Arrange, Act, Assert, with the traceability plugin of the reference. It runs first on the code as it is: a failing test at this point is a finding about the architecture.
tests/scenarios/, the plugin and the fixture without network in conftest.py, the marker in pyproject.toml, out/junit.xml.
python tools/traceability.py print the tree?[C] Character
You are the same test engineer. The test cases are in docs/test_cases.md.
[R] Request
1. Copy into tests/conftest.py the traceability plugin of the reference
package (lab/lesson-9/tcg_dataapp/tests/conftest.py, section
"traceability"), the fixture that blocks the network, and adapt the
fake source to the data of the DataApp.
2. Register the marker in pyproject.toml:
markers = ["scenario(id): the ATAM scenario of docs/scenarios.toml
that the test covers"] and addopts = "--strict-markers".
3. Implement each test case as one function in tests/scenarios/, marked
with @pytest.mark.scenario("Sxx") and with the id of the test case as
the first line of its docstring, following Arrange, Act, Assert.
4. Run pytest against the code AS IT IS, without fixing anything, and
keep the output: the passed and failed tests and the table "ATAM
traceability".
5. Run pytest --junitxml=out/junit.xml and
python tools/traceability.py (copied from the reference).
[E] Example
@pytest.mark.scenario("S04")
def test_s04_renamed_price_field_stops_the_run(settings):
"""TC04.1 a renamed price field stops the run"""
prices = rename(PRICES, "marketPrice", "market_price") # Arrange
ctx = pipeline.run(settings, client=FakeClient(prices=prices)) # Act
assert "check_quality" in ctx.results["_failed"] # Assert
[A] Adjustments
- A failing test is a result, not a bug of the test: do not change the
assertion to make it pass, and do not fix the DataApp in this step.
- Use fixtures for the environment and parametrize for variations of the
same stimulus.
- The whole suite must run without the network.
[T] Type of output
The tests, the output of pytest with the traceability table, and the
utility tree printed by tools/traceability.py.
[E] Extras
Show the plan before editing. Record this prompt in docs/prompts.md.
Stop at the end.
Step 06 · 1:45 · Findings · alone
Each failure and each pass says something about a decision of the architecture. The findings are classified, the risks of high importance are closed when time allows, and the suite runs again.
docs/results.md (both runs, the table of findings) and docs/traceability.md.
[C] Character
You are the architect again. The tests ran and the results are in
out/traceability.json and in the output of pytest.
[R] Request
1. Write docs/results.md with the first run: passed and failed tests,
and, for each failed scenario, what the failure shows about the
architecture.
2. Classify the findings in a table: risks (a decision that may prevent
a response), non-risks (a decision that the tests showed to be sound),
sensitivity points (a parameter or decision on which a response
depends) and tradeoffs (a decision that improves one attribute and
harms another). Each finding cites its scenarios.
3. For each risk of a scenario rated H in importance, propose the smallest
change of the code that closes it; implement the ones that fit in the
time of the session, run pytest again and record the second run.
4. Print the final utility tree with python tools/traceability.py and
write docs/traceability.md with python tools/traceability.py --markdown.
[E] Example
| Sensitivity point | the timestamp of noon UTC decides what is the
same batch; another hour breaks S01 | S01 |
[A] Adjustments
- A risk that was not closed stays in the table as open, with the reason.
- Do not remove a scenario because its test failed.
- Every number of docs/results.md comes from a run of this session.
[T] Type of output
docs/results.md, docs/traceability.md, the final tree and the output of
the second run of pytest.
[E] Extras
Show the classification before writing. Record this prompt in
docs/prompts.md. Stop at the end.
Step 07 · 1:55 · Pipeline · alone
A suite that runs only when someone remembers stops protecting the DataApp. On git.inteli.edu.br, a pipeline runs it on every push and every merge request, shows the failed tests in the merge request, and a daily schedule runs the DataApp on the real data.
.gitlab-ci.yml with the stages test, report and smoke; merge request !1 with its pipeline; the protection “Pipelines must succeed” and a schedule of main at 06:00 UTC.
[C] Character
You are the same test engineer. The suite passes on your machine; now it
must run on every push, without anyone remembering to run it, on the
GitLab of Inteli (git.inteli.edu.br).
[R] Request
1. .gitlab-ci.yml at the root of the repository, with the image
python:3.12-slim, a pip cache keyed by pyproject.toml, and three stages:
- test: two jobs that install the package and run pytest with
--junitxml, one for the tests of the package (tests/test_*.py) and
one for tests/scenarios; both publish the JUnit report with
artifacts:reports:junit, even when a test fails (when: always), and
the job of the scenarios keeps out/traceability.json;
- report: a job traceability that needs test:scenarios, runs also
after a failure (when: always) and publishes the table of
tools/traceability.py --markdown as an artifact;
- smoke: a job that runs only in a pipeline schedule:
tcg-dataapp run --with-today, then the check of freshness of S11.
2. workflow:rules so that a commit pushed to a branch with an open merge
request runs one pipeline (the merge request pipeline), not two.
3. Push the branch, open a merge request to main and show the pipeline,
the test report of the merge request and the artifact of the tree.
4. In Settings > Merge requests, turn on "Pipelines must succeed", and
in CI/CD > Schedules create a schedule of main at 0 6 * * * (UTC).
Facts measured on 12/11/2026 (confirm before use):
- the merge request pipeline of version 0.3.0: 9 tests in test:unit and
20 in test:scenarios, all passed; the tree reports 14 of 14 PASS.
- a commit that disables the gate of S04 (MAX_NULL_SHARE = 1.0) fails
test:scenarios with 1 test, TC04.1; traceability still runs and marks
S04 FAIL 1/2; with "Pipelines must succeed" the merge is blocked.
[E] Example
test:scenarios:
stage: test
script:
- pytest tests/scenarios --junitxml=out/junit-scenarios.xml
artifacts:
when: always
reports:
junit: out/junit-scenarios.xml
[A] Adjustments
- The pipeline has no secret and no network in the tests: the plugin of
conftest.py already blocks it. Only the smoke job uses the network.
- A failed test is never retried in CI and never marked allow_failure:
the red pipeline is the result that the merge request must show.
- Do not commit .venv/, out/ or warehouse/; .gitignore already lists them.
[T] Type of output
The file, the output of git push, and a description of what GitLab shows:
the pipeline graph, the test report and the widget of the merge request.
[E] Extras
Show the plan before editing. Record this prompt in docs/prompts.md.
Stop at the end.
Readings and videos assigned on Adalove, on pytest, and the reading material of the session, which covers the ATAM and the reference in full.
Introduction to pytest and to writing reliable test suites for Python projects.
Video covering pytest installation, fixtures, markers and test reports.
The method step by step, the fourteen scenarios of the reference, the prompts and the two runs, with the risks and tradeoffs found.
tcg-dataapp freshness on schedule.Automated Testing · 03/12/2026 · Prof. Afonso
By the end of the session, students should be able to derive the automated tests of a DataApp from its quality attributes with the ATAM, building the business drivers, a rated utility tree and quality attribute scenarios in six parts, implementing test cases traced to the scenarios as pytest tests in Arrange, Act, Assert, and reading the results back into the tree as risks, non-risks, sensitivity points and tradeoffs.
Short exposition followed by individual work graded in class. In 25 minutes the professor presents automated testing with pytest (levels of test, Arrange, Act, Assert, fixtures, parametrize and markers) and the ATAM, applied in full to the package of Lesson 7, whose first run failed 5 of 29 tests in three scenarios. Each student then applies the six steps alone to the DataApp of the group, with the CREATE prompts of the lab and a coding agent, while the professor circulates; this work is the graded DAG and Testing Activity on Adalove, delivered individually as a branch with a Prefect pipeline and the tests, documented in a pull request, by Friday.