Part 7 · Environment & Tests · Intermediate
Scenario Inheritance: Specialize Intent, Not Infrastructure
How child tests inherit base behavior and only override scenario policy through narrow, predictable methods.
Inheritance model
Use inheritance to express what changes per scenario , while inherited behavior preserves infra consistency.
[TEST][UVM][ENV] inheritance stack
base_test
├─ smoke_test
├─ error_injection_test
├─ burst_traffic_test
└─ low_power_resume_test
all derived tests share:
env build policy
timeout policy
report formattingclass burst_traffic_test extends base_test;
`uvm_component_utils(burst_traffic_test)
virtual function void configure_scenario();
super.configure_scenario();
cfg.txn_count = 2000;
cfg.enable_backpressure = 1;
endfunction
virtual task run_main_sequence();
burst_vseq seq = burst_vseq::type_id::create("seq");
seq.start(env.v_sqr);
endtask
endclassKey takeaways
Derived tests should read like scenario docs.
Call super methods unless intentionally replacing behavior.
Prefer cfg knobs over direct env internals in child tests.
Common pitfalls
Overriding build_phase in child tests without strong reason.
Duplicating run_phase in every child test.
Changing infrastructure defaults in scenario classes.
Scenario taxonomy patterns
Define scenario families so coverage planning and regression slicing are predictable.
Family matrix
[TEST] scenario family map
smoke/* -> short sanity tests (<1 min)
protocol/* -> legal/illegal protocol behaviors
stress/* -> long random and throughput scenarios
power/* -> reset/clock/power transition coverage
debug/* -> high-verbosity issue repro testsUse naming convention to derive testlist filters.
Keep one owner per family for review accountability.
Limit inheritance depth to two levels in most projects.
Extension-point policy
virtual function void set_scenario_id(string id);
scenario_id = id;
endfunction
virtual function void configure_sequences();
// choose sequence classes and base constraints
endfunction[TEST][ENV] policy
allowed child overrides:
configure_scenario
configure_sequences
optional run_main_sequence
discouraged child overrides:
build_phase
connect_phase
objection managementCommon pitfalls
Deep class trees that obscure active behavior.
Scenario IDs embedded only in class names, not logs.
No documented override policy for new contributors.