Stages dependencies?

Hello, I have a YAML file as below. Let’s say the *.md file is committed, the build does not work, but the test works. Here how can I make the test depend on the build? Like if the build doesn’t work, the test shouldn’t work.

Thanks in advance.

build:
  stage: build
  script:
    - echo "Build is running"
  only:
    changes:
      - Dockerfile
      - requirements.txt
      - ./configs/*
test:
  stage: test
  script:
    - echo "Test is running"
    - echo "$CI_JOB_STAGE"
  dependencies:
   - build