What is the correct way to start a sequencer from a test?

Hello,

There are several tutorials that have this kind of code in the test:

class base_test extends uvm_test;
  `uvm_component_utils(base_test)
  env myEnv;
  base_sequence seq;
  
  function new(string name, uvm_component parent);
    super.new(name, parent);
  endfunction
  
  virtual function void build_phase(uvm_phase phase);
    myEnv = env::type_id::create("myEnv", this);
    seq = base_sequence::type_id::create("seq");
  endfunction
  
  virtual task run_phase(uvm_phase phase);
    seq.start(null);
  endtask
endclass

I am not able to get this seq.start(null) to work. I get a run-time error:

UVM_FATAL @ 0: reporter@@seq [SEQ] neither the item's sequencer nor dedicated sequencer has been supplied to start item in seq

I read a comment saying start(null) starts the sequencer on a “default sequencer”. Is that an outdated concept in UVM? maybe related to `uvm_sequence_utils(seq,seqr)?

A related question about m_sequencer- it seems that m_sequencer gets initialized AFTER the sequence starts and is used to start more sequences on that sequencer. It can’t be accessed by the test because it is a “protected” property. Is that correct?

Is this the only way to start a sequence?

  virtual task run_phase(uvm_phase phase);
    seq.start(myEnv.agent1.sequencer);
  endtask

In reply to Pooja Pathak:

Yes,

You can only use a null sequencer whan starting a virtual sequence. Any sequence that generates sequence_items needs to be started on an existing sequencer.