Beispiel #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();
            });
        }
Beispiel #2
0
 public async Task TestOneMutant(Mutant mutant)
 {
     try
     {
         _log.Info("Testing process for mutant: " + mutant.Id);
         IObjectRoot <TestingMutant> testingMutant = _mutantTestingFactory.CreateWithParams(_sessionEventsSubject, mutant);
         await testingMutant.Get.RunAsync();
     }
     catch (Exception e)
     {
         _log.Error(e);
         mutant.MutantTestSession.ErrorMessage     = e.ToString();
         mutant.MutantTestSession.ErrorDescription = e.Message;
         mutant.State = MutantResultState.Error;
     }
     lock (this)
     {
         _testedNonEquivalentMutantsCount++;
         _testedMutantsCount++;
         _mutantsKilledCount = _mutantsKilledCount.IncrementedIf(mutant.State == MutantResultState.Killed);
         //AKB
         if (mutant.Id.IndexOf("First Order Mutant") != -1)
         {
             _numberOfFirstOrderMutants++;
         }
         RaiseTestingProgress();
     }
 }