stride3d/stride · error · InvalidOperationException

No [UITest] class named

Error message

No [UITest] class named '{testClassName}' in '{testDllPath}'. Available: {string.Join(", ", candidates.Select(t => t.FullName))}

What it means

LoadTest resolves the requested test class by name among the [UITest]-annotated candidates in the DLL. If a --test-name was given but no candidate's Name or FullName matches, it throws InvalidOperationException listing the available test class names. This distinguishes a bad test selection from a DLL with no tests at all.

Solutions

  1. Use one of the names listed in the error message (FullName or short Name).
  2. Run without --test-name if the DLL has exactly one test class so it is auto-selected.
  3. Fix the class name in the test project or update the CI/script argument.
  4. List candidates by scanning the DLL for [UITest] before running to confirm spelling.

Example fix

// before
dotnet Stride.GameStudio.AutoTesting.dll --test-dll MyTests.dll --test-name MyGameTest
// after (class is MyGameTests)
dotnet Stride.GameStudio.AutoTesting.dll --test-dll MyTests.dll --test-name MyGameTests
Defensive patterns

Strategy: validation

Validate before calling

var names = asm.GetTypes()
    .Where(t => t.GetCustomAttribute<UITestAttribute>() is not null)
    .SelectMany(t => new[] { t.Name, t.FullName });
if (testName is not null && !names.Contains(testName))
    throw new InvalidOperationException($"Unknown test '{testName}'. Available: {string.Join(", ", names)}");

Try / catch

try { test = LoadTest(dll, testName); }
catch (InvalidOperationException ex) { PrintAvailableTests(); return 1; }

Prevention

When it happens

Trigger: Passing --test-name with a class name that does not match any [UITest] class (wrong name, renamed class, or typo).

Common situations: A test class was renamed after scripts/CI were written; using the namespace-less short name when the attribute search expects exact Name or FullName; copy-pasting a test name from another project.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


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

Appendix: source

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

            return true;
        }
        return false;
    }

    private IUITest LoadTest()
    {
        var asm = Assembly.LoadFrom(testDllPath);
        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)
    {

View on GitHub (pinned to 96fad776d2)