Пример #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();
            });
        }
Пример #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();
     }
 }
Пример #3
0
 public void DisposeConfiguration()
 {
     if (_configuration != null)
     {
         _configuration.Get.Dispose();
         _configuration = null;
     }
 }
 public void DisposeConfiguration()
 {
     if (_configuration != null)
     {
         _configuration.Get.Dispose();
         _configuration = null;
     }
 }
Пример #5
0
 private void Clean()
 {
     _viewModel.Clean();
     if (_currentSessionController != null)
     {
         _currentSessionController.Get.MutantDetailsController.Clean();
     }
     if (_subscriptions != null)
     {
         foreach (var subscription in _subscriptions)
         {
             subscription.Dispose();
         }
     }
     _currentSessionController = null;
     SetState(OperationsState.None);
 }
        public void CreateConfiguration()
        {
            DisposeConfiguration();
            var optionsModel = _optionsManager.ReadOptions();


            IWhiteSource whiteCache;
            if (optionsModel.WhiteCacheThreadsCount != 0)
            {
                whiteCache = _whiteCacheFactory.CreateWithParams(optionsModel.WhiteCacheThreadsCount, optionsModel.WhiteCacheThreadsCount);
            }
            else
            {
                whiteCache = _whiteCacheFactory.CreateWithParams(1, 1);
            }
            whiteCache.Initialize();
            _configuration = _continuousConfigurationFactory.CreateWithBindings(optionsModel, whiteCache);
        }
Пример #7
0
        public void CreateConfiguration()
        {
            DisposeConfiguration();
            var optionsModel = _optionsManager.ReadOptions();

            IWhiteSource whiteCache;

            if (optionsModel.WhiteCacheThreadsCount != 0)
            {
                whiteCache = _whiteCacheFactory.CreateWithParams(optionsModel.WhiteCacheThreadsCount, optionsModel.WhiteCacheThreadsCount);
            }
            else
            {
                whiteCache = _whiteCacheFactory.CreateWithParams(1, 1);
            }
            whiteCache.Initialize();
            _configuration = _continuousConfigurationFactory.CreateWithBindings(optionsModel, whiteCache);
        }
Пример #8
0
        public void TestMemory()
        {
            var modules = new INinjectModule[]
            {
                new TestModule(),
            };

            _kernel = new StandardKernel();
            _kernel.Components.Add <IActivationStrategy, MyMonitorActivationStrategy>();

            _kernel.Load(modules);

            var factory = _kernel.Get <IRootFactory <SomeMainModule> >();

            for (int i = 0; i < 10000; i++)
            {
                IObjectRoot <SomeMainModule> someMainModule = factory.Create();
                someMainModule.Get.CreateSub();
                var s = someMainModule as ObjectRoot <SomeMainModule>;
                //   s.Kernel.Dispose();
            }
        }
Пример #9
0
        public async Task RunMutationSession(MethodIdentifier methodIdentifier = null, List <string> testAssemblies = null, bool auto = false)
        {
            //_host.Build();
            _log.Info("Showing mutation session window.");

            var continuousConfiguration = _continuousConfigurator.GetConfiguration();
            var sessionConfiguration    = await Task.Run(() => continuousConfiguration.Get.CreateSessionConfiguration());

            try
            {
                IObjectRoot <SessionController> sessionController =
                    await sessionConfiguration.Get.CreateSession(methodIdentifier, testAssemblies, auto);

                Clean();
                _sessionConfiguration     = sessionConfiguration;
                _currentSessionController = sessionController;

                _viewModel.MutantDetailsViewModel = _currentSessionController.Get.MutantDetailsController.ViewModel;

                Subscribe(_currentSessionController.Get);

                try
                {
                    _log.Info("Starting mutation session...");
                    await _currentSessionController.Get.RunMutationSession(_controlSource);
                }
                catch (TaskCanceledException)
                {
                    _log.Info("Session cancelled.");
                }
            }
            catch (TaskCanceledException)
            {
                // cancelled by user
                _log.Info("Session creation cancelled.");
            }
        }
Пример #10
0
 private void Clean()
 {
     _viewModel.Clean();
     if (_currentSessionController != null)
     {
         _currentSessionController.Get.MutantDetailsController.Clean();
     }
     if (_subscriptions!=null)
     {
         foreach (var subscription in _subscriptions)
         {
             subscription.Dispose();
         }
     }
     _currentSessionController = null;
     SetState(OperationsState.None);
 }
Пример #11
0
        public async Task RunMutationSession(MethodIdentifier methodIdentifier = null, List<string> testAssemblies = null,  bool auto = false)
        {
            //_host.Build();
            _log.Info("Showing mutation session window.");

            var continuousConfiguration = _continuousConfigurator.GetConfiguration();
            var sessionConfiguration = await Task.Run(() => continuousConfiguration.Get.CreateSessionConfiguration());
            
            try
            {
                IObjectRoot<SessionController> sessionController = 
                    await sessionConfiguration.Get.CreateSession(methodIdentifier, testAssemblies, auto);

                Clean();
                _sessionConfiguration = sessionConfiguration;
                _currentSessionController = sessionController;

                _viewModel.MutantDetailsViewModel = _currentSessionController.Get.MutantDetailsController.ViewModel;

                Subscribe(_currentSessionController.Get);

                try
                {
                    _log.Info("Starting mutation session...");
                    await _currentSessionController.Get.RunMutationSession(_controlSource);
                }
                catch (TaskCanceledException)
                {
                    _log.Info("Session cancelled.");
                }
            }
            catch (TaskCanceledException)
            {
                // cancelled by user
                _log.Info("Session creation cancelled.");
            }
        }