Esempio n. 1
0
        public async Task RunCore()
        {
            _mutantDetailsController.Initialize();

            _currentSession = new MutationTestingSession
            {
                Filter  = _choices.Filter,
                Choices = _choices,
            };

            if (_choices.TestAssemblies.All(n => n.IsIncluded == false))
            //if (_choices.TestAssemblies.Select(a => a.TestsLoadContext.SelectedTests.TestIds.Count).Sum() == 0)
            {
                throw new NoTestsSelectedException();
            }

            _log.Info("Initializing test environment...");

            _log.Info("Creating pure mutant for initial checks...");
            AssemblyNode assemblyNode;
            Mutant       changelessMutant = _mutantsContainer.CreateEquivalentMutant(out assemblyNode);

            _sessionEventsSubject.OnNext(new MutationFinishedEventArgs(OperationsState.MutationFinished)
            {
                MutantsGrouped = assemblyNode.InList(),
            });

            var verifiEvents = _sessionEventsSubject
                               .OfType <MutantVerifiedEvent>()
                               .Subscribe(e =>
            {
                if (e.Mutant == changelessMutant && !e.VerificationResult)
                {
                    _svc.Logging.ShowWarning(UserMessages.ErrorPretest_VerificationFailure(
                                                 changelessMutant.MutantTestSession.Exception.Message));
                }
            });

            IObjectRoot <TestingMutant> testingMutant = _testingMutantFactory
                                                        .CreateWithParams(_sessionEventsSubject, changelessMutant);

            var result = await testingMutant.Get.RunAsync();

            verifiEvents.Dispose();

            _choices.MutantsTestingOptions.TestingTimeoutSeconds
                = (int)((_options.TimeFactorForMutations * changelessMutant.MutantTestSession.TestingTimeMiliseconds) + 1);

            bool canContinue = CheckForTestingErrors(changelessMutant);

            if (!canContinue)
            {
                throw new TestingErrorsException();
            }
            await Task.Run(() =>
            {
                CreateMutants();
                RunTests();
            });
        }