Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw more specific exception when test class fails to be instantiated #136

Open
paulegradie opened this issue Nov 29, 2023 · 0 comments
Open

Comments

@paulegradie
Copy link
Owner

When building tests and a registration is missing or some other issue prevents a test class from being instantiated for a given test case, a vanilla exception is thrown.

It would be ideal to have a more specific (custom?) exception that describes this scenario - which may even be used for additional filtering when reporting test results for example:

        catch (Exception ex)
        {
            exceptionCallback?.Invoke(testCaseEnumerator.Current);

            await DisposeOfTestInstance(testCaseEnumerator.Current);
            testCaseEnumerator.Dispose();
            var msg = $"Error resolving test from {testProvider.Test.FullName}";
            Log.Logger.Fatal(ex, "{Message}", msg);
            if (exceptionCallback is null) throw;

            var testCaseEnumerationException = new TestCaseEnumerationException(ex, $"Failed to create test cases for {testProvider.Test.FullName}");
            return new List<TestCaseExecutionResult>() { new(testCaseEnumerationException) };
        }

Or something to that effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant