from pants.backend.project_info.rules import ListTargets from pants.engine.goal import Goal from pants.testutil.rule_runner import RuleRunner def test_list_targets() -> None: rule_runner = RuleRunner(rules=[ListTargets], target_types=["foo_target"]) foo_target = Target(f"foo_target", TargetWithSources([])) rule_runner.add_to_build_file("", "foo_target()") result = rule_runner.run_goal_rule(Goal("list"), [], ["--type=foo_target"]) assert result.stdout == foo_target.address.spec + "\n"This example shows how the `RuleRunner` can be used to test the `ListTargets` rule from the `pants.backend.project_info.rules` package. The `goal_name` parameter is set to `"list"`, which is the name of the `Goal` that is being tested. The `global_args` and `args` parameters are set to `[]` and `["--type=foo_target"]` respectively, which ensures that the rule is being run with the correct arguments. Package Library: pants.backend.project_info