Esempio n. 1
0
 public override void RunTests(IEnumerable <ITestCase> testCases, IMessageSink executionMessageSink, ITestFrameworkExecutionOptions executionOptions)
 {
     executionOptions.SetValue(nameof(ElasticXunitRunOptions.Version), this.Options.Version);
     executionOptions.SetValue(nameof(ElasticXunitRunOptions.RunIntegrationTests), this.Options.RunIntegrationTests);
     executionOptions.SetValue(nameof(ElasticXunitRunOptions.RunUnitTests), this.Options.RunUnitTests);
     executionOptions.SetValue(nameof(ElasticXunitRunOptions.TestFilter), this.Options.TestFilter);
     executionOptions.SetValue(nameof(ElasticXunitRunOptions.ClusterFilter), this.Options.ClusterFilter);
     base.RunTests(testCases, executionMessageSink, executionOptions);
 }
Esempio n. 2
0
        public override void RunAll(IMessageSink executionMessageSink, ITestFrameworkDiscoveryOptions discoveryOptions, ITestFrameworkExecutionOptions executionOptions)
        {
            discoveryOptions.SetValue(nameof(ElasticXunitRunOptions.Version), this.Options.Version);
            discoveryOptions.SetValue(nameof(ElasticXunitRunOptions.RunIntegrationTests), this.Options.RunIntegrationTests);
            discoveryOptions.SetValue(nameof(ElasticXunitRunOptions.RunUnitTests), this.Options.RunUnitTests);
            discoveryOptions.SetValue(nameof(ElasticXunitRunOptions.TestFilter), this.Options.TestFilter);
            discoveryOptions.SetValue(nameof(ElasticXunitRunOptions.ClusterFilter), this.Options.ClusterFilter);

            executionOptions.SetValue(nameof(ElasticXunitRunOptions.Version), this.Options.Version);
            executionOptions.SetValue(nameof(ElasticXunitRunOptions.RunIntegrationTests), this.Options.RunIntegrationTests);
            executionOptions.SetValue(nameof(ElasticXunitRunOptions.RunUnitTests), this.Options.RunUnitTests);
            executionOptions.SetValue(nameof(ElasticXunitRunOptions.TestFilter), this.Options.TestFilter);
            executionOptions.SetValue(nameof(ElasticXunitRunOptions.ClusterFilter), this.Options.ClusterFilter);

            base.RunAll(executionMessageSink, discoveryOptions, executionOptions);
        }
Esempio n. 3
0
 protected override async void RunTestCases(IEnumerable <IXunitTestCase> testCases,
                                            IMessageSink executionMessageSink,
                                            ITestFrameworkExecutionOptions executionOptions)
 {
     executionOptions.SetValue("xunit.execution.DisableParallelization", false);
     using (var assemblyRunner = new Runner(
                TestAssembly, testCases, DiagnosticMessageSink, executionMessageSink,
                executionOptions)) await assemblyRunner.RunAsync();
 }
Esempio n. 4
0
        protected override async void RunTestCases(IEnumerable <IXunitTestCase> testCases, IMessageSink sink,
                                                   ITestFrameworkExecutionOptions options)
        {
            options.SetValue(nameof(ElasticXunitRunOptions.Version), Options.Version);
            options.SetValue(nameof(ElasticXunitRunOptions.RunIntegrationTests), Options.RunIntegrationTests);
            options.SetValue(nameof(ElasticXunitRunOptions.IntegrationTestsMayUseAlreadyRunningNode),
                             Options.IntegrationTestsMayUseAlreadyRunningNode);
            options.SetValue(nameof(ElasticXunitRunOptions.RunUnitTests), Options.RunUnitTests);
            options.SetValue(nameof(ElasticXunitRunOptions.TestFilter), Options.TestFilter);
            options.SetValue(nameof(ElasticXunitRunOptions.ClusterFilter), Options.ClusterFilter);
            try
            {
                using (var runner =
                           new TestAssemblyRunner(TestAssembly, testCases, DiagnosticMessageSink, sink, options))
                {
                    Options.OnBeforeTestsRun();
                    await runner.RunAsync().ConfigureAwait(false);

                    Options.OnTestsFinished(runner.ClusterTotals, runner.FailedCollections);
                }
            }
            catch (Exception e)
            {
                if (e is ElasticsearchCleanExitException || e is AggregateException ae &&
                    ae.Flatten().InnerException is ElasticsearchCleanExitException)
                {
                    sink.OnMessage(new TestAssemblyCleanupFailure(Enumerable.Empty <ITestCase>(), TestAssembly,
                                                                  new ElasticsearchCleanExitException("Node failed to start", e)));
                }
Esempio n. 5
0
            protected override async void RunTestCases(IEnumerable <IXunitTestCase> testCases, IMessageSink executionMessageSink, ITestFrameworkExecutionOptions executionOptions)
            {
                SetupTracing(TestAssembly.Assembly);

                // Always run at least with one thread per VS version.
                if (executionOptions.MaxParallelThreadsOrDefault() < VsVersions.InstalledVersions.Length && !Debugger.IsAttached)
                {
                    executionOptions.SetValue("xunit.execution.MaxParallelThreads", VsVersions.InstalledVersions.Length);
                    Constants.Tracer.TraceEvent(TraceEventType.Verbose, 0, Strings.VsixTestFramework.SettingMaxThreads(VsVersions.InstalledVersions.Length));
                }
                // If debugger is attached, don't run multiple instances simultaneously since that makes debugging much harder.
                if (Debugger.IsAttached)
                {
                    executionOptions.SetValue("xunit.execution.MaxParallelThreads", 1);
                    Constants.Tracer.TraceEvent(TraceEventType.Verbose, 0, Strings.VsixTestFramework.DebugMaxThreads);
                }

                // This is the implementation of the base XunitTestFrameworkExecutor
                using (var assemblyRunner = new VsixTestAssemblyRunner(TestAssembly, testCases, DiagnosticMessageSink, new TracingMessageSink(executionMessageSink, Constants.Tracer), executionOptions))
                    await assemblyRunner.RunAsync();

                s_tracer.Flush();
            }
Esempio n. 6
0
 /// <summary>
 /// Sets a flag that determines whether xUnit.net should report test results synchronously.
 /// </summary>
 public static void SetSynchronousMessageReporting(this ITestFrameworkExecutionOptions executionOptions, bool value)
 {
     executionOptions.SetValue(TestOptionsNames.Execution.SynchronousMessageReporting, value);
 }
Esempio n. 7
0
 /// <summary>
 /// Sets the maximum number of threads to use when running tests in parallel.
 /// If set to 0 (the default value), does not limit the number of threads.
 /// </summary>
 public static void SetMaxParallelThreads(this ITestFrameworkExecutionOptions executionOptions, int value)
 {
     executionOptions.SetValue(TestOptionsNames.Execution.MaxParallelThreads, value);
 }
Esempio n. 8
0
 /// <summary>
 /// Sets a flag to disable parallelization.
 /// </summary>
 public static void SetDisableParallelization(this ITestFrameworkExecutionOptions executionOptions, bool value)
 {
     executionOptions.SetValue(TestOptionsNames.Execution.DisableParallelization, value);
 }
Esempio n. 9
0
 /// <summary>
 /// Sets a flag that determines whether diagnostic messages will be emitted.
 /// </summary>
 public static void SetDiagnosticMessages(this ITestFrameworkExecutionOptions executionOptions, bool value)
 {
     executionOptions.SetValue(TestOptionsNames.Execution.DiagnosticMessages, value);
 }
 /// <summary>
 /// Sets a flag that determines whether xUnit.net stop testing when a test fails.
 /// </summary>
 public static void SetStopOnTestFail(this ITestFrameworkExecutionOptions executionOptions, bool?value)
 {
     executionOptions.SetValue(TestOptionsNames.Execution.StopOnFail, value);
 }
 protected override void RunTestCases(IEnumerable<IXunitTestCase> testCases, IMessageSink executionMessageSink, ITestFrameworkExecutionOptions executionOptions)
 {
     executionOptions.SetValue("xunit.execution.SynchronousMessageReporting", (bool?)true);
     executionOptions.SetValue("xunit.execution.DisableParallelization", (bool?)true);
     base.RunTestCases(testCases, executionMessageSink, executionOptions);
 }
 protected override void RunTestCases(IEnumerable <IXunitTestCase> testCases, IMessageSink executionMessageSink, ITestFrameworkExecutionOptions executionOptions)
 {
     executionOptions.SetValue("xunit.execution.SynchronousMessageReporting", (bool?)true);
     executionOptions.SetValue("xunit.execution.DisableParallelization", (bool?)true);
     base.RunTestCases(testCases, executionMessageSink, executionOptions);
 }