stride3d/stride · error · InvalidOperationException

Multiple [UITest] classes in

Error message

Multiple [UITest] classes in '{testDllPath}'; pass --test-name to select. Available: {string.Join(", ", candidates.Select(t => t.FullName))}

What it means

When no --test-name is supplied, LoadTest auto-selects the single [UITest] class in the DLL. If the DLL contains multiple annotated classes, it throws InvalidOperationException telling the user to pass --test-name and listing the available classes. Ambiguity must be resolved explicitly.

Solutions

  1. Add --test-name <ClassName> to the launch command specifying which test to run.
  2. Split tests into separate DLLs if you want each to be auto-selected.
  3. Remove or mark obsolete the tests you no longer intend to run.
  4. Update the CI/launch script to select the test explicitly.

Example fix

// before
Stride.GameStudio.AutoTesting.exe --test-dll MyTests.dll
// after
Stride.GameStudio.AutoTesting.exe --test-dll MyTests.dll --test-name SmokeTest
Defensive patterns

Strategy: validation

Validate before calling

var count = asm.GetTypes().Count(t => t.GetCustomAttribute<UITestAttribute>() is not null);
if (count > 1 && testName is null)
    throw new InvalidOperationException("Multiple [UITest] classes: --test-name is required");

Try / catch

try { test = LoadTest(dll, testName); }
catch (InvalidOperationException) { testName = PromptForTestName(); test = LoadTest(dll, testName); }

Prevention

When it happens

Trigger: Running the host with a test DLL containing two or more [UITest] classes and omitting --test-name.

Common situations: Accumulating several UI test classes in one test project over time while the launch command still predates the second test; CI jobs that only ever ran one test.

Understand the failure class

Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/4d45f8fd08496507. Report an issue: GitHub.

Appendix: source

Thrown at sources/editor/Stride.GameStudio.AutoTesting/UITestHost.cs:170

        var candidates = asm.GetTypes()
            .Where(t => t.GetCustomAttribute<UITestAttribute>() is not null)
            .ToList();
        if (candidates.Count == 0)
            throw new InvalidOperationException($"No [UITest] class found in '{testDllPath}'.");

        Type chosen;
        if (testClassName is not null)
        {
            chosen = candidates.FirstOrDefault(t => t.Name == testClassName || t.FullName == testClassName)
                ?? throw new InvalidOperationException($"No [UITest] class named '{testClassName}' in '{testDllPath}'. Available: {string.Join(", ", candidates.Select(t => t.FullName))}");
        }
        else if (candidates.Count == 1)
        {
            chosen = candidates[0];
        }
        else
        {
            throw new InvalidOperationException($"Multiple [UITest] classes in '{testDllPath}'; pass --test-name to select. Available: {string.Join(", ", candidates.Select(t => t.FullName))}");
        }

        if (!typeof(IUITest).IsAssignableFrom(chosen))
            throw new InvalidOperationException($"[UITest] class {chosen.FullName} must implement IUITest.");

        return (IUITest)Activator.CreateInstance(chosen)!;
    }

    private void RunTest(IUITest test, Context ctx)
    {
        Task.Run(async () =>
        {
            var status = "ok";
            object? exceptionInfo = null;
            try
            {
                await test.Run(ctx);
            }

View on GitHub (pinned to 96fad776d2)