Module 8 Β· Information Systems Β· Lesson 9 Β· Week 9

Automated Testing

Reference material for the session in which each student derives the tests of the DataApp of the group from its quality attributes, with the ATAM: business drivers, a rated utility tree, quality attribute scenarios in six parts, test cases traced to them, a pytest suite run on the code as it is, and the findings read back into the tree. The method is applied in full to the package of Lesson 7, whose first run failed 5 of 29 tests in three scenarios.

About this session

Automated Testing Β· 03/12/2026 Β· Prof. Afonso

Learning objective

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.

Session strategy

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.

Session structure

  1. Daily β€” 15 min
  2. Automated tests, levels of test and pytest β€” 10 min
  3. The ATAM: drivers, utility tree, six-part scenarios and findings; the reference β€” 15 min
  4. Steps 01–02 alone: drivers, attributes and utility tree β€” 15 min
  5. Step 03 alone: scenarios in six parts β€” 15 min
  6. Steps 04–05 alone: test cases, tests and first run β€” 35 min
  7. Step 06 alone: findings, second run and delivery β€” 15 min
Part IFoundations

1. How to read this material

This material accompanies Lesson 9, which has two hours. In the first 25 minutes after the daily, the professor presents automated testing with pytest and the Architecture Tradeoff Analysis Method (ATAM). From then on each student works alone, applying the six steps of the method to the DataApp of the group with the CREATE prompts of the lab. The work done in the session is the in-class graded activity, whose statement and criteria are delivered in class and are not kept in this public repository.

Part I presents the reasons for automated tests and the tools of pytest. Part II presents the ATAM as used in this session: business drivers, utility tree, quality attribute scenarios and the classification of findings. Part III shows how scenarios become test cases and test functions traced to them. Part IV applies the whole method to the package of Lesson 7 and records its two runs. Part V gathers the six steps with their prompts, the recurring mistakes, a glossary and the references. Every number was measured on 08/11/2026 with the reference package of lab/lesson-9/tcg_dataapp/ (version 0.3.0), Python 3.12.3, DuckDB 2.0.0 and pytest.

2. Why a DataApp needs automated tests

A DataApp runs every day without a person, and each property that someone once checked by reading a result, such as a grain that holds, a rerun that duplicates nothing or a frozen report that never changes, remains true only while the code that guarantees it is not changed. An automated test turns such a property into code that checks it at every change, so that a change that breaks it fails before it reaches the main branch. In Lesson 7 the package received nine tests of this kind, which run in about two seconds without the network.

A test also has two roles beyond regression. It is a specification: test_a_month_with_two_captures_freezes_only_the_last states the semi-additive rule of Lesson 6 in a form that a machine checks. And it constrains the design, because only decoupled code can be tested in isolation; the ETL layer of the package receives its client as a parameter, which is what allows the tests to replace the source by a fake one.

The nine tests of Lesson 7, however, cover the behaviours that the author remembered while writing the package. The question that this session answers is different: which behaviours does the partner depend on, and which of them are tested? Answering it requires deriving the tests from the quality attributes that the business requires, which is what the ATAM does.

3. Levels of test

Tests differ in the size of what they exercise. The test pyramid, popularised by Mike Cohn, recommends many fast tests at the base, which exercise one function, and few slow tests at the top, which exercise the whole system; the lower the level, the more precisely a failure points to its cause, and the higher the level, the closer the test is to what the user observes. In a data pipeline, two further kinds are frequent: contract tests, which check the shape of an output that other systems read, and performance tests, which check a measure of time under a given volume.

LevelExercisesExample in the reference packageTime
unitone function, without I/Oorder() rejects a cycle; freeze_month rejects a month that is not YYYY-MMmilliseconds
integrationone layer with a real DuckDB in memorya batch loaded twice is replaced; the gates of check_goldtens of milliseconds
contractthe shape of an output read by othersthe Parquet marts against docs/contracts/marts.jsontenths of a second
end to endthe whole pipeline with a fake sourcea full run, a rerun, a source down, a renamed fieldtenths of a second
performancea measure of time under a volume100,000 synthetic prices from build_gold to write_reportabout 1.3 s

The quality gates of Lesson 7 are themselves tests of the data, which run in production on every run. The tests of this session check that those gates stop the run when they must, and that they do not stop it when the data is sound.

4. pytest: Arrange, Act, Assert

A test in pytest is a function whose name starts with test_, in a file whose name starts with test_. It follows the pattern Arrange, Act, Assert: it prepares the situation, performs one action and checks the outcome with plain assert statements, which pytest rewrites to report the values that differed when a check fails. The test below is one of the test cases of scenario S04 of the reference.

tests/scenarios/test_correctness.py
@pytest.mark.scenario("S04")
def test_s04_renamed_price_field_stops_the_run(settings):
    """TC04.1 a renamed price field stops the run"""
    prices = copy.deepcopy(PRICES)
    for rows in prices["2026-09-01"].values():
        for r in rows:
            r["market_price"] = r.pop("marketPrice")
    ctx = pipeline.run(settings, client=FakeClient(prices=prices), echo=quiet)
    assert "check_quality" in ctx.results["_failed"]
    con = duckdb.connect(str(settings.db_path), read_only=True)
    detail = con.execute("SELECT detail FROM ops.pipeline_runs WHERE task = 'check_quality'").fetchone()[0]
    assert "null market price" in detail
ResourceWhat it doesUse in this session
fixturea function that prepares a resource and is injected by name into the tests that ask for itthe environment of a scenario: settings with a temporary folder; no_network, applied to every test
@pytest.mark.parametrizeruns the same test over a list of inputsvariations of the same stimulus
markera label on a test, registered in pyproject.toml@pytest.mark.scenario("S04") ties the test to its scenario
monkeypatchreplaces an attribute or an environment variable during one testthe clock of now_unix, the variables TCG_*, the client of the pipeline
tmp_patha temporary folder per testthe DuckDB file and the outputs of each run
--junitxmlwrites the results in the JUnit XML formatthe report that a continuous integration server reads
Part IIThe ATAM

5. The ATAM and what this session keeps of it

The Architecture Tradeoff Analysis Method was developed at the Software Engineering Institute of Carnegie Mellon University to evaluate a software architecture against the quality attributes that its business goals require (Kazman, Klein and Clements, 2000). In its full form, an evaluation team, the architects and the stakeholders meet over several days: the business drivers and the architecture are presented, the architectural approaches are identified, a utility tree is built and prioritised, the approaches are analysed against the scenarios of highest priority, the stakeholders propose further scenarios, and the results are presented as risks, non-risks, sensitivity points and tradeoffs.

This session keeps the artefacts of the method and replaces the analysis by discussion with execution. Each scenario receives a response measure that a test can check, and the result of the test is the evidence that the architecture achieves the response or fails to achieve it. A scenario whose measure is not checked by a test remains a hypothesis about the architecture.

Step of the sessionArtefactCorrespondence in the ATAM
01 business drivers and quality attributesdocs/business_drivers.mdpresentation of the business drivers
02 utility treedocs/utility_tree.md, docs/scenarios.tomlgeneration of the quality attribute utility tree
03 scenarios in six partsdocs/scenarios.mdrefinement of the leaves of highest priority
04 test casesdocs/test_cases.md(added) the scenario as verifiable cases
05 tests run on the code as it istests/scenarios/, out/junit.xmlanalysis of the architectural approaches, by execution
06 results into the treedocs/results.md, docs/traceability.mdpresentation of risks, non-risks, sensitivity points and tradeoffs

6. Business drivers and quality attributes

A business driver states what the system exists for and what the organisation needs from it, and each driver has consequences for the architecture. The quality attributes follow from the drivers: an attribute that no driver justifies is not analysed, because nothing in the business depends on it. The five drivers of the reference were written from the README of the package and from the conditions of the source.

CodeDriverConsequence for the architecture
BD1Collectors and analysts decide purchases from the answers of the report; a wrong number costs more than a late one.The run must stop before it publishes a number it cannot vouch for.
BD2The frozen monthly report is cited after the month ends.A frozen report is never rebuilt, whatever arrives later.
BD3The source is a free public mirror without a service level.Failures of the source are expected events, handled by retries, gates and checks of freshness.
BD4The DataApp runs every day without a person, on modest hardware.Each run is idempotent and logged, and the processing fits a small machine.
BD5The team changes the model every sprint.The tests run in seconds, without the network.

From these drivers come eight quality attributes: correctness, reliability, auditability, interoperability, timeliness, performance, testability and modifiability. Security is absent from the reference because the DataApp reads public data and publishes nothing personal; in a DataApp that handles data of people, it would follow from a driver and would have its own branch of the tree, which Lesson 13 discusses.

7. The utility tree

The utility tree organises the quality attributes in levels. The root is the utility of the system; the first level holds the attributes, the second their refinements, and each leaf is a concrete scenario. Each leaf receives two ratings, each H, M or L: its importance for the business drivers and the difficulty, for the architecture, of achieving it. The pair orders the analysis, starting from the leaves rated (H,H) and (H,M); a leaf rated (L,L) can wait, and a leaf rated (L,H) deserves the question of why it is in the tree at all.

docs/utility_tree.md of the reference
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
β”‚   β”œβ”€β”€ Frozen report never changes .... S08 (H,L)
β”‚   └── Every attempt is logged ........ S09 (M,L)
β”œβ”€β”€ Interoperability
β”‚   └── Contract of the marts .......... S10 (M,L)
β”œβ”€β”€ Timeliness
β”‚   └── Stale data is detected ......... S11 (M,L)
β”œβ”€β”€ Performance
β”‚   └── Processing budget .............. S12 (M,M)
β”œβ”€β”€ Testability
β”‚   └── Tests without network .......... S13 (M,L)
└── Modifiability
    └── Sets by configuration .......... S14 (L,L)

A leaf names a situation that can happen to the system, such as "the source renames a field", and never a wish, such as "the system is robust". The difference is practical: only a situation can be reproduced by a test.

8. Quality attribute scenarios in six parts

A leaf of the tree is still a sentence. The quality attribute scenario, in the form of Bass, Clements and Kazman (2021), makes it precise in six parts: the source that generates a stimulus; the stimulus that reaches the system; the artifact that receives it; the environment, or state of the system, when it happens; the response of the system; and the response measure, which states how the response is checked. The measure is the part that connects the scenario to a test, because it becomes the assertions of the test.

PartS07 of the reference, (H,M)
Sourcetcgcsv.com
Stimulusis down during the whole run
Artifactpipeline.py and cli.py
Environmentunattended daily run after a successful run
Responsethe run fails naming the task, skips its dependents and leaves what was published
Response measureexit code 1; no new row in db_ingestion; out/report.md byte-identical

The fourteen scenarios of the reference are kept in docs/scenarios.toml, which is the single source of the tree, of the tables of docs/scenarios.md and of the traceability report. The table below gives the stimulus and the measure of each one.

ScenarioPrioritySource and stimulusResponse measure
S01(H,M)the scheduler runs the pipeline a second time on the same day, with the prices of todaythe fact has the same rows as after the first run, and rows = keys of the grain
S02(H,M)a defect in an extraction loads the prices of a day twice, with two timestampsthe run ends FAILED naming check_quality; out/report.md is byte-identical to the previous one
S03(H,M)TCGplayer through tcgcsv publishes prices of a product that is not in the catalogue captured by the runthe count is in the result of check_quality; more than 1 % of the prices of a capture stops the run
S04(H,H)TCGplayer through tcgcsv renames the field marketPrice in the prices of one capture, or adds a new fieldmore than 10 % of null market prices in a capture stops the run (real maximum 1.7 %); a new field changes no number
S05(H,H)the daily runs bring a second capture of a month before the month is frozeneach card appears once in the frozen report, with the price of the last capture
S06(H,L)tcgcsv.com fails the first request of the runone failed and one successful attempt in ops.pipeline_runs; the same rows as a run without failure
S07(H,M)tcgcsv.com is down during the whole runexit code 1; no new row in db_ingestion; out/report.md byte-identical
S08(H,L)a late capture brings new prices of a month that is already frozenthe rows of the frozen table are identical before and after
S09(M,L)the operator audits a run that had a retryone success per task; started_at <= ended_at, both BIGINT; status in success, failed, skipped
S10(M,L)a dashboard of the partner reads out/marts/*.parquet after a change in the modelthe schema of every Parquet file equals the contract; any difference fails the build
S11(M,L)tcgcsv.com stops publishing new prices while the runs keep succeedingexit code 1 when the last capture is older than 2 days, detected at the first check after that
S12(M,M)a year of daily captures the landing table grows to 100,000 pricesless than 10 s from build_gold to write_report
S13(M,L)a developer runs the whole suite on a laptop without networkno connection opened; the suite ends in less than 30 s on a student laptop
S14(L,L)the team changes the list of sets and dateszero lines of code changed; only the configured sets reach gold.dim_set

When a number of the measure comes from the real data, it is measured before it is written. The limit of S04, more than 10 % of null market prices in a capture, was set after measuring that the real captures have at most 1.7 % of null prices, in the capture of 2026-09-01.

9. Risks, non-risks, sensitivity points and tradeoffs

KindDefinitionExample in the reference
riskan architectural decision that may prevent the system from achieving a responsethe inner join of gold.fact_price drops a price whose product is not in the catalogue, and no check notices (S03)
non-riska decision that the analysis showed to be soundreading the JSON by field name makes a new field of the source change no number (S04, TC04.2)
sensitivity pointa parameter or decision on which a response dependsthe timestamp of noon UTC decides what is the same batch; another hour breaks the idempotency of S01
tradeoffa decision that improves one attribute and worsens anothera stricter quality gate publishes fewer wrong numbers and causes more failed runs: correctness against availability (S02 to S04)

The classification is the output of the method. A list of passed and failed tests says what happened; the classification says what it means for the next decision of the team, and it keeps the tradeoffs that were accepted on purpose apart from the risks that were found by accident.

Part IIIFrom scenarios to tests

10. Deriving test cases

A test case fixes the abstract parts of a scenario as concrete data. The stimulus becomes something the test can produce, such as a fake source that renames a field; the environment becomes a fixture, such as a warehouse after a successful run; and the response measure becomes the assertions. A scenario whose measure has several conditions, or whose stimulus has variants, yields more than one test case. Every test case traces to exactly one scenario, and a test case that traces to none is not written, because nothing in the business depends on it.

Test caseScenarioWhat it checksTest function
TC01.1S01second run of the archive dates keeps the facttest_s01_second_run_keeps_the_fact
TC01.2S01two runs with the prices of today keep one price per product and daytest_s01_two_runs_today_keep_one_price_per_product
TC02.1S02a broken grain stops the run and keeps the previous reporttest_s02_broken_grain_stops_the_run_and_keeps_the_report
TC02.2S02the quality gate is attempted oncetest_s02_the_quality_gate_is_attempted_once
TC03.1S03prices without product are countedtest_s03_prices_without_product_are_counted
TC03.2S03above 1 % of a capture the run stopstest_s03_above_one_percent_the_run_stops
TC04.1S04a renamed price field stops the runtest_s04_renamed_price_field_stops_the_run
TC04.2S04a new field changes nothingtest_s04_new_field_changes_nothing
TC05.1S05two captures of a month freeze only the lasttest_s05_two_captures_of_a_month_freeze_only_the_last
TC06.1S06one failure is absorbed by a retrytest_s06_one_failure_is_absorbed_by_a_retry
TC07.1S07the run fails and publishes nothingtest_s07_source_down_publishes_nothing
TC07.2S07the command returns exit code 1test_s07_the_command_returns_exit_code_1
TC08.1S08late prices of a frozen month do not change ittest_s08_late_prices_of_a_frozen_month_do_not_change_it
TC09.1S09the log of a run with a retry is completetest_s09_the_log_of_a_run_with_a_retry_is_complete
TC10.1S10the Parquet files follow the contracttest_s10_the_parquet_files_follow_the_contract
TC11.1S11fresh data passestest_s11_fresh_data_passes
TC11.2S11data older than 2 days fails the checktest_s11_data_older_than_two_days_fails
TC12.1S12100,000 prices processed within the budgettest_s12_processing_fits_the_budget
TC13.1S13the suite cannot open a connectiontest_s13_the_suite_cannot_open_a_connection
TC14.1S14TCG_SETS and TCG_PRICE_DATES drive the runtest_s14_sets_and_dates_come_from_the_environment

The twenty test cases are implemented as twenty functions in tests/scenarios/. Together with the nine tests of Lesson 7, which remain as unit and integration tests without a scenario, the suite has 29 tests.

11. Traceability in the code

The link between a test and its scenario is a marker, registered in pyproject.toml with --strict-markers, so that a misspelt marker fails the collection. The first line of the docstring carries the id of the test case. A small plugin in tests/conftest.py reads docs/scenarios.toml, refuses a test that declares a scenario that does not exist, records the outcome of each traced test, prints one line per scenario at the end of the run and writes out/traceability.json. The option --scenario S04 runs only the tests of one scenario.

tests/conftest.py Β· traceability
# --------------------------------------------------------------- traceability
SCENARIOS: dict[str, dict] = {}
OUTCOMES: dict[str, list[tuple[str, str, str]]] = {}
STARTED = [0.0]


def pytest_addoption(parser):
    parser.addoption("--scenario", action="append", default=[],
                     help="run only the tests of this ATAM scenario (repeatable), e.g. --scenario S04")


def pytest_configure(config):
    path = Path(config.rootpath) / "docs" / "scenarios.toml"
    SCENARIOS.update({s["id"]: s for s in tomllib.loads(path.read_text(encoding="utf-8"))["scenario"]})
    STARTED[0] = time.perf_counter()


def _scenario_of(item):
    mark = item.get_closest_marker("scenario")
    return mark.args[0] if mark else None


def pytest_collection_modifyitems(config, items):
    for item in items:
        sid = _scenario_of(item)
        if sid is not None and sid not in SCENARIOS:
            raise pytest.UsageError(f"{item.nodeid} declares scenario {sid}, which is not in docs/scenarios.toml")
    wanted = set(config.getoption("--scenario"))
    if wanted:
        keep = [i for i in items if _scenario_of(i) in wanted]
        config.hook.pytest_deselected(items=[i for i in items if i not in keep])
        items[:] = keep


def pytest_runtest_logreport(report):
    if report.when == "call" or (report.when == "setup" and report.outcome != "passed"):
        sid = dict(report.user_properties).get("scenario")
        if sid:
            case = dict(report.user_properties).get("case", "")
            OUTCOMES.setdefault(sid, []).append((report.nodeid.split("::")[-1], case, report.outcome))


@pytest.hookimpl(tryfirst=True)
def pytest_runtest_setup(item):
    sid = _scenario_of(item)
    if sid:
        doc = (item.function.__doc__ or "").strip().splitlines()
        item.user_properties.append(("scenario", sid))
        item.user_properties.append(("case", doc[0] if doc else ""))


def pytest_terminal_summary(terminalreporter, config):
    if not OUTCOMES:
        return
    elapsed = time.perf_counter() - STARTED[0]
    tr = terminalreporter
    tr.section("ATAM traceability")
    rows = []
    selected = set(config.getoption("--scenario")) or set(SCENARIOS)
    for sid, s in SCENARIOS.items():
        if sid not in selected:
            continue
        results = OUTCOMES.get(sid, [])
        passed = sum(1 for *_, o in results if o == "passed")
        status = "NOT COVERED" if not results else ("PASS" if passed == len(results) else "FAIL")
        rows.append({"id": sid, "attribute": s["attribute"], "refinement": s["refinement"],
                     "priority": f"({s['importance']},{s['difficulty']})", "tests": len(results),
                     "passed": passed, "status": status,
                     "cases": [{"test": t, "case": c, "outcome": o} for t, c, o in results]})
        name = f"{s['attribute']} Β· {s['refinement']}"
        tr.write_line(f"{sid}  {rows[-1]['priority']}  {name:48.48} {passed}/{len(results)}  {status}")
    tr.write_line(f"suite time {elapsed:.2f} s")
    out = Path(config.rootpath) / "out"
    out.mkdir(exist_ok=True)
    (out / "traceability.json").write_text(json.dumps({"suite_seconds": round(elapsed, 2), "scenarios": rows},
                                                      indent=2), encoding="utf-8")
python tools/traceability.py, after pytest (excerpt)
Utility
β”œβ”€β”€ Correctness
β”‚   β”œβ”€β”€ Idempotent runs
β”‚   β”‚   └── S01 (H,M) PASS 2/2
β”‚   β”œβ”€β”€ No wrong number published
β”‚   β”‚   └── S02 (H,M) PASS 2/2
β”‚   β”œβ”€β”€ Every price reaches the model
β”‚   β”‚   └── S03 (H,M) PASS 2/2
β”‚   β”œβ”€β”€ Schema drift of the source
β”‚   β”‚   └── S04 (H,H) PASS 2/2
...
└── Modifiability
    └── Sets by configuration
        └── S14 (L,L) PASS 1/1

12. A fake source and a suite without network

All tests run against a fake client of tcgcsv with two sets, four products and prices on two dates. The parameter prices lets a test change what the source publishes, which is how the stimuli of S03, S04 and S05 are produced, and fail_times makes the first calls fail, which produces the stimuli of S06 and S07. An autouse fixture replaces the connection of every socket by an error, so that a test that tries to reach the network fails instead of passing slowly; scenario S13 checks that this block is in force.

tests/conftest.py Β· the fake source and the block of the network
class FakeClient:
    """The source of the tests. prices can replace PRICES to simulate a change of the source."""

    def __init__(self, fail_times: int = 0, prices: dict | None = None):
        self.fail_times = fail_times
        self.calls = 0
        self.prices = copy.deepcopy(PRICES) if prices is None else prices

    def groups(self):
        self.calls += 1
        if self.calls <= self.fail_times:
            raise ConnectionError("tcgcsv is down")
        return list(SETS.values()) + [{"groupId": 99, "name": "Other", "abbreviation": "OT", "publishedOn": "2020-01-01T00:00:00"}]

    def products(self, group_id):
        return PRODUCTS[group_id]

    def prices_archive(self, day, group_ids):
        return {g: self.prices[day].get(g, []) for g in group_ids}

    def prices_today(self, group_id):
        return self.prices["2026-09-01"].get(group_id, [])


@pytest.fixture
def settings(tmp_path):
    return Settings(db_path=tmp_path / "tcg.duckdb", out_dir=tmp_path / "out", sets=(1, 2),
                    price_dates=("2026-08-01", "2026-09-01"), frozen_month="2026-08", retries=1, retry_delay=0)


@pytest.fixture(autouse=True)
def no_network(monkeypatch):
    """Scenario S13: no test may open a connection; the fake source is the only source."""
    def refuse(*args, **kwargs):
        raise RuntimeError("network blocked by the test suite")
    monkeypatch.setattr(socket.socket, "connect", refuse)
    monkeypatch.setattr(socket, "create_connection", refuse)

13. Three scenarios as tests

The scenario S02 requires that a broken grain stop the run before anything is published. Its test first runs the pipeline successfully, keeps the bytes of the report, simulates a defective extractor that loads the prices of a day twice, and runs again.

S02 Β· TC02.1
@pytest.mark.scenario("S02")
def test_s02_broken_grain_stops_the_run_and_keeps_the_report(settings):
    """TC02.1 a broken grain stops the run and keeps the previous report"""
    pipeline.run(settings, client=FakeClient(), echo=quiet)
    before = (settings.out_dir / "report.md").read_bytes()
    con = duckdb.connect(str(settings.db_path))
    # a defective extractor loads the prices of 2026-09-01 again, one hour later
    con.execute("INSERT INTO db_ingestion SELECT timestamp + 3600, data_json, data_tag FROM db_ingestion "
                "WHERE data_tag = 'tcgplayer.price.v1' AND timestamp = ?", [extract.unix("2026-09-01")]).fetchall()
    con.close()
    ctx = pipeline.run(settings, client=FakeClient(), echo=quiet)
    assert {"check_quality", "freeze_reports", "export_marts", "write_report"} <= set(ctx.results["_failed"])
    assert (settings.out_dir / "report.md").read_bytes() == before

The scenario S07 checks the response to a source that is down for the whole run, comparing the report, the marts and the landing table before and after.

S07 Β· TC07.1
@pytest.mark.scenario("S07")
def test_s07_source_down_publishes_nothing(settings):
    """TC07.1 the run fails and publishes nothing"""
    pipeline.run(settings, client=FakeClient(), echo=quiet)
    report = (settings.out_dir / "report.md").read_bytes()
    marts = {p.name: p.read_bytes() for p in (settings.out_dir / "marts").iterdir()}
    rows = landing_rows(settings)
    ctx = pipeline.run(settings, client=FakeClient(fail_times=99), echo=quiet)
    assert "extract_sets" in ctx.results["_failed"] and "write_report" in ctx.results["_failed"]
    assert landing_rows(settings) == rows
    assert (settings.out_dir / "report.md").read_bytes() == report
    assert {p.name: p.read_bytes() for p in (settings.out_dir / "marts").iterdir()} == marts

The scenario S12 builds a synthetic landing table of 2,000 cards over 50 weekly captures, 100,000 prices, and measures the time from build_gold to write_report against a budget of 10 seconds. Three runs measured 1.12, 1.25 and 1.45 seconds.

S12 Β· TC12.1
@pytest.mark.scenario("S12")
def test_s12_processing_fits_the_budget(tmp_path):
    """TC12.1 100,000 prices processed within the budget"""
    con = duckdb.connect(str(tmp_path / "big.duckdb"))
    synthetic_landing(con)
    t0 = time.perf_counter()
    gold.build_gold(con)
    measured = quality.check_gold(con)
    gold.freeze_month(con, "2026-03")
    report.export_marts(con, tmp_path / "out")
    report.write_report(con, tmp_path / "out")
    elapsed = time.perf_counter() - t0
    print(f"S12: {measured['fact_rows']:,} prices processed in {elapsed:.2f} s")
    assert measured["fact_rows"] == PRODUCTS * CAPTURES
    assert elapsed < BUDGET_S
Part IVThe reference applied

14. First run: the package of Lesson 7 as it was

ScenarioResult on 0.1.0What the failure showed
S03 (H,M) every price reaches the modelFAIL 0/2A price of a product that is not in the catalogue disappears in the inner join of gold.fact_price, and no check notices. The check fact_without_set of 0.1.0 could never fail, because the fact already joins gold.dim_set.
S04 (H,H) schema driftFAIL 1/2When the source renames marketPrice, every price of the capture becomes null, the cube drops them and the run ends OK, publishing a report without that capture. A new field changes nothing (TC04.2 passed).
S11 (M,L) stale dataFAIL 0/2No command or check reports the age of the last capture, so runs that keep succeeding over old data are indistinguishable from good runs.

The scenarios were written and their tests were run against the package of Lesson 7 without any change. Of the 29 tests, 24 passed and 5 failed, in three scenarios. The failures are findings about the architecture: the nine tests of Lesson 7 passed throughout, because none of them reproduced these stimuli.

15. The changes of version 0.3.0

Each risk of high importance received the smallest change that closes it. The quality gate now compares, capture by capture, the prices of the landing table with the prices that reached the fact, and stops the run when more than 1 % of a capture is lost or when more than 10 % of its market prices are null. The vacuous check was removed. The freshness of the data became a function and a command, tcg-dataapp freshness --max-age-days 2, which returns exit code 1 when the last capture is older than the limit.

src/tcg_dataapp/processors/quality.py
"""Checks that stop the pipeline when the gold layer is wrong, and the check of freshness.

Version 0.3.0 adds two checks found by the ATAM scenarios of Lesson 9:
S03, prices of the landing table that never reach the fact, and S04, a
capture whose market prices became null because the source renamed a
field. The check of 0.1.0 that counted prices without a set was removed:
gold.fact_price is an inner join with gold.dim_set, so it could never fail.
"""
from __future__ import annotations

import duckdb

from tcg_dataapp.etls.landing import run

MAX_DROPPED_SHARE = 0.01  # S03: share of the prices of a capture that may miss the fact
MAX_NULL_SHARE = 0.10     # S04: share of null market prices in a capture (real maximum 1.7 %)


class QualityError(RuntimeError):
    pass


class StaleDataError(RuntimeError):
    pass


def check_gold(con: duckdb.DuckDBPyConnection, max_dropped_share: float = MAX_DROPPED_SHARE,
               max_null_share: float = MAX_NULL_SHARE) -> dict:
    """Return the measured numbers, or raise QualityError naming the check that failed."""
    m = {}
    for tag in ("tcgplayer.set.v1", "tcgplayer.product.v1", "tcgplayer.price.v1"):
        m[tag] = run(con, "SELECT count(*) FROM db_ingestion WHERE data_tag = ?", [tag])[0][0]
        if m[tag] == 0:
            raise QualityError(f"db_ingestion has no rows of {tag}")
    rows, keys = run(con, "SELECT count(*), count(DISTINCT (date_unix, product_id, variant)) FROM gold.fact_price")[0]
    m["fact_rows"], m["fact_grain_keys"] = rows, keys
    if rows != keys:
        raise QualityError(f"grain of gold.fact_price broken: {rows} rows for {keys} keys")

    # S03: every price of the landing table reaches the fact, capture by capture
    per_capture = run(con, """
        WITH landing AS (SELECT timestamp // 86400 * 86400 AS date_unix, count(*) AS n
                         FROM db_ingestion WHERE data_tag = 'tcgplayer.price.v1' GROUP BY 1),
             fact AS (SELECT date_unix, count(*) AS n,
                             count(*) FILTER (WHERE market_price IS NULL) AS nulls
                      FROM gold.fact_price GROUP BY 1)
        SELECT l.date_unix, l.n, coalesce(f.n, 0), coalesce(f.nulls, 0)
        FROM landing l LEFT JOIN fact f USING (date_unix) ORDER BY 1""")
    m["prices_not_in_fact"] = sum(n - in_fact for _, n, in_fact, _ in per_capture)
    for date_unix, n, in_fact, nulls in per_capture:
        dropped = (n - in_fact) / n
        if dropped > max_dropped_share:
            raise QualityError(f"{n - in_fact} of {n} prices of the capture {date_unix} did not reach "
                               f"gold.fact_price ({dropped:.1%} > {max_dropped_share:.0%})")
        null_share = nulls / in_fact if in_fact else 1.0
        if null_share > max_null_share:
            raise QualityError(f"{nulls} of {in_fact} prices of the capture {date_unix} have a null market price "
                               f"({null_share:.1%} > {max_null_share:.0%}); did the source rename a field?")
    m["max_null_price_share"] = round(max((nulls / in_fact for _, _, in_fact, nulls in per_capture if in_fact),
                                          default=0.0), 4)
    m["dates"] = run(con, "SELECT count(*) FROM gold.dim_date")[0][0]
    m["cube_cells"] = run(con, "SELECT count(*) FROM gold.agg_price_cube")[0][0]
    return m


def check_freshness(con: duckdb.DuckDBPyConnection, now: int, max_age_days: float = 2) -> float:
    """S11: age in days of the last capture; raise StaleDataError when it is older than max_age_days."""
    last = run(con, "SELECT max(timestamp) FROM db_ingestion WHERE data_tag = 'tcgplayer.price.v1'")[0][0]
    if last is None:
        raise StaleDataError("db_ingestion has no prices")
    age = (now - last) / 86400
    if age > max_age_days:
        raise StaleDataError(f"last capture {last} is {age:.1f} days old (limit {max_age_days:g} days)")
    return round(age, 2)

16. Second run and the real data

MeasureValue
suite on 0.1.024 passed, 5 failed (S03 0/2, S04 1/2, S11 0/2)
suite on 0.3.029 passed without network, in 8.8 s on an idle machine and 12.5 to 17.3 s on a loaded one; 14 of 14 scenarios PASS
real run of 0.3.0 over tcgcsv12 tasks ok in 25 s; 5,951 prices; 524 cells; 1,226 rows frozen in September
new measures on the real dataprices_not_in_fact 0; max_null_price_share 0.017
freshness on 08/11/2026fresh: last capture 1.0 days old (limit 2 days), exit code 0
S12100,000 synthetic prices in 1.1 to 1.5 s, budget 10 s

The real run confirms that the new gates do not stop sound data: the limits of 1 % and 10 % lie above the real maxima of 0 % and 1.7 %. Choosing these limits is a tradeoff between correctness and availability, recorded as such in the findings.

17. Findings of the reference

KindFindingScenarios
Risk (closed in 0.3.0)prices lost silently in the join of the factS03
Risk (closed in 0.3.0)a renamed field of the source publishes a report without pricesS04
Risk (closed in 0.3.0)stale data undetectedS11
Risk (open)check_freshness exists but nothing calls it on schedule; Lesson 10 turns it into a metric with an alertS11
Risk (open)the contract of the marts covers names and types, not the meaning of a columnS10
Non-riska transient failure is absorbed by one retry, with the same rows as a clean runS06
Non-riska frozen report keeps its rows when late prices of its month arriveS08
Non-riska new field in the source changes no number, because the JSON is read by nameS04
Sensitivity pointthe timestamp of noon UTC decides what is the same batch; another hour breaks S01S01
Sensitivity pointthe inner joins of gold.fact_price decide which prices reach the modelS03
Sensitivity pointthe limits of 1 % and 10 % of the quality gateS03, S04
Tradeoffcorrectness against availability: a stricter gate publishes fewer wrong numbers and more failed runs; the limits were set above the real maxima (0 % and 1.7 %)S02, S03, S04
Tradeoffthe gold layer as views keeps the model always current (S01) and makes every report recompute it, which S12 boundsS01, S12

Two risks remain open. The check of freshness exists, but nothing calls it on schedule, which Lesson 10 addresses by turning it into a metric with an alert. The contract of the marts covers the names and types of the columns, not their meaning, so a column that keeps its type and changes its unit would pass the test.

Part VLab

18. The seven steps, alone

From 0:40 on, each student applies the six steps of the method to the DataApp of the group, packaged in Lesson 7, alone and with a coding agent, and in a seventh step puts the suite in a pipeline of the GitLab of Inteli. The starting point must be a green suite: pip install -e '.[dev]' and pytest pass before the first prompt. The reference package shows the form of each artefact; its content belongs to the TCGplayer DataApp and does not transfer to the data of the partner.

Step 01 Β· Business drivers and quality attributes Β· from 0:40

Prompt 01 Β· CREATE
[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.

Done when:

  • each driver states a need and its consequence for the architecture
  • each attribute cites at least one driver
  • the hypotheses are marked as such

Step 02 Β· Utility tree Β· from 0:48

Prompt 02 Β· CREATE
[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.

Done when:

  • every leaf is a situation, not a wish
  • every H is justified in one sentence
  • the order of analysis is written

Step 03 Β· Scenarios in six parts Β· from 0:55

Prompt 03 Β· CREATE
[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.

Done when:

  • every measure is a number or a verifiable condition
  • the numbers taken from the real data were measured first
  • the scenarios still empty are listed

Step 04 Β· Test cases Β· from 1:10

Prompt 04 Β· CREATE
[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.

Done when:

  • every test case traces to one scenario
  • the level of each case is stated
  • no case depends on the network

Step 05 Β· Tests, run on the code as it is Β· from 1:20

Prompt 05 Β· CREATE
[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.

Done when:

  • pytest ends with the table "ATAM traceability"
  • the first run was kept, with its failures
  • tools/traceability.py prints the tree

Step 06 Β· Results into the tree Β· from 1:45

Prompt 06 Β· CREATE
[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.

Done when:

  • each finding cites its scenarios
  • the risks left open are marked as open, with the reason
  • every number comes from a run of this session

Step 07 Β· The GitLab pipeline Β· from 1:55

A suite that runs only when someone remembers to run it stops protecting the DataApp at the first change made in a hurry. Continuous integration removes that dependence: every push to git.inteli.edu.br starts a pipeline that installs the package in a clean container and runs the tests, so the result of each commit is known before anyone merges it. The file .gitlab-ci.yml of the reference divides the work in three stages. In test, two jobs run in parallel, one for the nine tests of the package and one for the twenty tests of the scenarios, and each publishes its JUnit report even when a test fails, because GitLab reads those reports to show the failed tests in the merge request. In report, the job traceability waits only for the scenarios (needs) and runs also after a failure (when: always), so the artifact of the utility tree says which leaves failed. In smoke, a job that runs only in a pipeline schedule collects the data of the day from tcgcsv.com and checks the freshness of S11, which turns the open risk of S11 into a check made every morning.

The pipeline protects the main branch only when the project requires it. With β€œPipelines must succeed” turned on in the settings of merge requests, a red pipeline blocks the merge, and the fix of a failing scenario is a change of the code, never of the assertion. The recording of the reference, made on 12/11/2026 with the same image in Docker, shows the three situations. The merge request pipeline passed 29 tests in about 24 s. A commit that set MAX_NULL_SHARE = 1.0, the kind of change that makes a stopped run pass, failed the test case TC04.1, and the job of the tree still ran and marked S04 FAIL 1/2. The scheduled pipeline ran the DataApp on the real data in about 55 s. The project needs a runner available to it; without one, the pipeline stays pending.

Prompt 07 Β· CREATE
[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.

Done when:

  • the merge request shows the test report of both test jobs
  • a failing scenario turns the pipeline red and blocks the merge
  • the job of the tree runs also after a failure, and the schedule of main exists

19. The graded activity

The work of this session is the in-class graded activity. Each student, alone, applies the six steps of the method to the DataApp of the group: the business drivers and quality attributes, the rated utility tree, the scenarios in six parts, the test cases traced to them, the tests implemented and run on the code as it is, and the findings read back into the tree. The statement is the DAG and Testing Activity on Adalove. The work is individual and is done on a branch of the project repository named graded-activity/student-name, which holds a Prefect pipeline, as built in Lesson 8, and the unit tests derived in the six steps. The implementation, the testing approach and the instructions of use are documented in a pull request, and only the link is submitted, by the Friday of the same week (04/12/2026). The criteria are those listed in the activity on Adalove. On git.inteli.edu.br the pull request is a merge request, and the pipeline of step 07 runs the tests of the branch on each push and shows their report in it.

20. Recurring mistakes

Changing the assertion until the test passes

When a test fails on the first run, coding agents tend to adjust the assertion or the fixture until it passes. A failure in step 05 is a finding about the architecture and must be kept; the prompt of step 05 forbids changing the assertion, and step 06 decides what to do about the failure.

Measures that cannot be checked

A measure such as "the pipeline is reliable" or "the report is fast" cannot become an assertion. The measure needs a number or a verifiable condition, such as "exit code 1" or "less than 10 s on 100,000 prices", and a number taken from the real data is measured before it is written.

Leaves that are wishes, and everything rated H

A tree whose leaves are qualities ("robust", "scalable") has no scenario to test, and a tree in which every leaf is rated (H,H) gives no order of analysis. The ratings are relative: within one DataApp, some leaves matter more than others.

Tests that reach the network

A test that calls the real source is slow, fails when the source is down and passes or fails for reasons outside the code. The fixture that blocks the network turns such a test into an immediate failure, which shows where the fake source is missing.

21. Glossary

TermMeaning in this lesson
ATAMArchitecture Tradeoff Analysis Method, of the Software Engineering Institute
business driverwhat the organisation needs from the system, with its consequence for the architecture
quality attributea measurable property of the system that a driver requires, such as reliability or performance
utility treequality attributes refined into concrete scenarios, each rated (importance, difficulty)
quality attribute scenariosource, stimulus, artifact, environment, response and response measure
test casea scenario fixed as concrete data, fixture and assertions
traceabilitythe link from each test to its scenario and from each scenario to its tests
riska decision that may prevent a response
non-riska decision shown to be sound
sensitivity pointa parameter or decision on which a response depends
tradeoffa decision that improves one attribute and worsens another
fixturea resource prepared by pytest and injected into a test by name
markera label on a test, such as scenario("S04")
contract testa test of the shape of an output that other systems read

22. Checklist

  • The suite was green before the first prompt.
  • Each quality attribute cites the business driver that justifies it.
  • Each leaf of the utility tree is a situation, rated (importance, difficulty).
  • The scenarios of highest priority have six parts and a measurable response.
  • Each test case traces to one scenario, and each test carries the marker of its scenario.
  • The suite runs without the network and prints the traceability table.
  • The first run was kept with its failures.
  • The findings are classified as risks, non-risks, sensitivity points and tradeoffs.
  • The open risks are recorded with the reason.

23. References and self-study

  • KAZMAN, R.; KLEIN, M.; CLEMENTS, P. ATAM: Method for Architecture Evaluation. Technical Report CMU/SEI-2000-TR-004. Pittsburgh: Software Engineering Institute, Carnegie Mellon University, 2000.
  • BASS, L.; CLEMENTS, P.; KAZMAN, R. Software Architecture in Practice. 4. ed. Boston: Addison-Wesley, 2021. Chapter 3: quality attribute scenarios; chapter 21: architecture evaluation.
  • COHN, M. Succeeding with Agile: Software Development Using Scrum. Boston: Addison-Wesley, 2009. The test automation pyramid.
  • pytest documentation: fixtures, markers, parametrize and the JUnit XML report. docs.pytest.org.
  • Pytest: Getting started with automated testing for Python (self-study 1, 30 min).
  • PyTest Tutorial for Beginners: Complete Guide to Python Testing (self-study 2, video, 100 min).