MCPcopy Create free account
hub / github.com/bigdra50/unity-cli / tests_run

Function tests_run

unity_cli/cli/commands/tests.py:124–188  ·  view source on GitHub ↗

Run EditMode or PlayMode tests and wait for results. By default runs every test in the chosen mode and polls until completion, printing a live progress summary. Filters are ANDed together. Examples: u tests run edit # All EditMode tests

(
    ctx: typer.Context,
    mode: Annotated[str, typer.Argument(help="Test mode (edit or play)", autocompletion=_complete_test_mode)] = "edit",
    test_names: Annotated[
        list[str] | None,
        typer.Option("--test-names", "-n", help="Specific test names"),
    ] = None,
    categories: Annotated[
        list[str] | None,
        typer.Option("--categories", "-c", help="Test categories"),
    ] = None,
    assemblies: Annotated[
        list[str] | None,
        typer.Option("--assemblies", "-a", help="Assembly names"),
    ] = None,
    group_pattern: Annotated[
        str | None,
        typer.Option("--group-pattern", "-g", help="Regex pattern for test names"),
    ] = None,
    no_wait: Annotated[
        bool,
        typer.Option("--no-wait", help="Return immediately without waiting for results"),
    ] = False,
)

Source from the content-addressed store, hash-verified

122
123@tests_app.command("run")
124def tests_run(
125 ctx: typer.Context,
126 mode: Annotated[str, typer.Argument(help="Test mode (edit or play)", autocompletion=_complete_test_mode)] = "edit",
127 test_names: Annotated[
128 list[str] | None,
129 typer.Option("--test-names", "-n", help="Specific test names"),
130 ] = None,
131 categories: Annotated[
132 list[str] | None,
133 typer.Option("--categories", "-c", help="Test categories"),
134 ] = None,
135 assemblies: Annotated[
136 list[str] | None,
137 typer.Option("--assemblies", "-a", help="Assembly names"),
138 ] = None,
139 group_pattern: Annotated[
140 str | None,
141 typer.Option("--group-pattern", "-g", help="Regex pattern for test names"),
142 ] = None,
143 no_wait: Annotated[
144 bool,
145 typer.Option("--no-wait", help="Return immediately without waiting for results"),
146 ] = False,
147) -> None:
148 """Run EditMode or PlayMode tests and wait for results.
149
150 By default runs every test in the chosen mode and polls until completion,
151 printing a live progress summary. Filters are ANDed together.
152
153 Examples:
154 u tests run edit # All EditMode tests
155 u tests run play # All PlayMode tests
156 u tests run edit -a Game.Tests.Editor # One assembly
157 u tests run edit -g "SceneTest" # Regex on test name
158 u tests run edit -n Ns.MyTests.MyCase # Single test (full name)
159 u tests run edit --no-wait # Fire and forget (poll later via 'tests status')
160 """
161 context: CLIContext = ctx.obj
162 try:
163 result = context.client.tests.run(
164 mode=mode,
165 test_names=test_names,
166 categories=categories,
167 assemblies=assemblies,
168 group_pattern=group_pattern,
169 )
170
171 if no_wait:
172 print_success(result.get("message", "Tests started"))
173 return
174
175 # Auto-poll for results
176 from unity_cli.cli.output import print_test_results_table
177
178 final = _poll_test_results(context)
179
180 if "tests" in final:
181 print_test_results_table(final["tests"])

Callers

nothing calls this directly

Calls 8

print_successFunction · 0.90
print_test_results_tableFunction · 0.90
print_key_valueFunction · 0.90
_handle_errorFunction · 0.90
_poll_test_resultsFunction · 0.85
ExitMethod · 0.80
runMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected