{"record":{"id":"5db6c3218bdba87c","repo":"apache/beam","slug":"no-tests-found-if-you-haven-t-added-a-set-of-tests-yet-you","errorCode":null,"errorMessage":"No tests found. If you haven't added a set of tests yet, you can get started by running your pipeline with the --create_test flag enabled.","messagePattern":"No tests found\\. If you haven't added a set of tests yet, you can get started by running your pipeline with the --create_test flag enabled\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/yaml/main.py","lineNumber":185,"sourceCode":"\n  if known_args.create_test and known_args.fix_tests:\n    raise ValueError(\n        'At most one of --create_test and --fix_tests may be specified.')\n  elif known_args.create_test:\n    result = unittest.TestResult()\n    tests = []\n  else:\n    if known_args.test_suite:\n      with open(known_args.test_suite) as fin:\n        test_suite_holder = yaml.load(\n            fin, Loader=yaml_transform.SafeLineLoader) or {}\n    else:\n      test_suite_holder = pipeline_spec\n    test_specs = test_suite_holder.get('tests', [])\n    if not isinstance(test_specs, list):\n      raise TypeError('tests attribute must be a list of test specifications.')\n    elif not test_specs:\n      raise RuntimeError(\n          'No tests found. '\n          \"If you haven't added a set of tests yet, you can get started by \"\n          'running your pipeline with the --create_test flag enabled.')\n\n    tests = [\n        yaml_testing.YamlTestCase(\n            pipeline_spec, test_spec, options, known_args.fix_tests)\n        for test_spec in test_specs\n    ]\n    suite = unittest.TestSuite(tests)\n    result = unittest.TextTestRunner().run(suite)\n\n  if known_args.fix_tests or known_args.create_test:\n    update_tests(known_args, pipeline_yaml, pipeline_spec, options, tests)\n\n  if exit:\n    # emulates unittest.main()\n    sys.exit(0 if result.wasSuccessful() else 1)","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/yaml/main.py#L167-L203","documentation":"Raised by run_tests in apache_beam.yaml.main when a YAML test suite resolves to an empty or missing 'tests' list. The YAML pipeline spec loaded (or provided inline) contains no 'tests' entries, so there is nothing to run. Beam throws this to distinguish 'your tests failed' from 'you never defined any tests'.","triggerScenarios":"Running `python -m apache_beam.yaml.main --test_suite file.yaml` (or a pipeline with test-parsing args) where the top-level mapping has no 'tests' key, or 'tests: []'. Also triggered when the loaded spec is not a dict and defaults to an empty test list.","commonSituations":"Developers enable --fix_tests or test mode on a plain YAML pipeline file that has no tests section yet; CI pipelines pointed at a test-suite file that was created as an empty stub ('tests: []'); typos like 'test:' instead of 'tests:'.","solutions":["Add a 'tests:' list with at least one test specification to the YAML file.","Run the pipeline once with the --create_test flag to scaffold an empty tests section, then fill in test cases.","Verify the key is exactly 'tests' and is a list of test mappings, not a mapping or misspelled key."],"exampleFix":"// before\npipeline:\n  type: ReadFromPubsub\n  ...\n// after\npipeline:\n  type: ReadFromPubsub\n  ...\ntests:\n  - name: basic\n    elements: [1, 2, 3]\n    expected: [2, 4, 6]","handlingStrategy":"validation","validationCode":"import yaml\nspec = yaml.safe_load(open(suite_path))\ntests = spec.get('tests', []) if isinstance(spec, dict) else []\nif not isinstance(tests, list) or not tests:\n    raise SystemExit('Test suite has no tests; add a tests: list or use --create_test')","typeGuard":"def has_tests(spec) -> bool:\n    return isinstance(spec, dict) and isinstance(spec.get('tests'), list) and len(spec['tests']) > 0","tryCatchPattern":"try:\n    run_tests(...)\nexcept RuntimeError as e:\n    if 'No tests found' in str(e):\n        scaffold_tests_with_create_test_flag()  # rerun with --create_test\n    else:\n        raise","preventionTips":["Always keep at least one entry under tests: in test-suite files","Never commit empty 'tests: []' stubs to CI","CI-lint YAML pipelines to require the tests key when test mode is on"],"tags":["yaml","testing","beam-yaml"],"backgroundTag":"empty-required-field","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}