示例#1
0
    /// <inheritdoc />
    protected override async void RunTestCases(
        IEnumerable <IXunitTestCase> testCases,
        IMessageSink executionMessageSink,
        ITestFrameworkExecutionOptions executionOptions)
    {
        var   exceptions = new List <Exception>();
        IHost?host       = null;

        try
        {
            host = _hostManager.BuildDefaultHost();
        }
        catch (TargetInvocationException tie)
        {
            exceptions.Add(tie.InnerException);
        }
        catch (Exception ex)
        {
            exceptions.Add(ex);
        }

        // ReSharper disable once PossibleMultipleEnumeration
        var hostMap = testCases
                      .GroupBy(tc => tc.TestMethod.TestClass, TestClassComparer.Instance)
                      .ToDictionary(group => group.Key, group =>
        {
            try
            {
                return(_hostManager.GetHost(group.Key.Class.ToRuntimeType()));
            }
            catch (TargetInvocationException tie)
            {
                exceptions.Add(tie.InnerException);
            }
            catch (Exception ex)
            {
                exceptions.Add(ex);
            }

            return(null);
        });

        try
        {
            await _hostManager.StartAsync(default).ConfigureAwait(false);