private async Task TestExecutionStartingAsync(IOperation operation)
        {
            cancelling        = false;
            runningInParallel = false;
            StopCoverage();

            var settings = appOptionsProvider.Get();

            if (!settings.Enabled)
            {
                CombinedLog("Coverage not collected as FCC disabled.");
                reportGeneratorUtil.EndOfCoverageRun();
                return;
            }

            msCodeCoverageCollectionStatus = await msCodeCoverageRunSettingsService.IsCollectingAsync(testOperationFactory.Create(operation));

            if (msCodeCoverageCollectionStatus == MsCodeCoverageCollectionStatus.NotCollecting)
            {
                if (settings.RunInParallel)
                {
                    runningInParallel = true;
                    fccEngine.ReloadCoverage(() =>
                    {
                        return(testOperationFactory.Create(operation).GetCoverageProjectsAsync());
                    });
                }
                else
                {
                    CombinedLog("Coverage collected when tests finish. RunInParallel option true for immediate");
                }
            }
        }
Beispiel #2
0
 private async Task CollectingIfUserRunSettingsOnlyAsync()
 {
     if (!coverageProjectsByType.HasTemplated())
     {
         collectionStatus = MsCodeCoverageCollectionStatus.Collecting;
         await CombinedLogAsync($"{msCodeCoverageMessage} with user runsettings");
     }
 }
Beispiel #3
0
 private Task InitializeIsCollectingAsync(ITestOperation testOperation)
 {
     collectionStatus  = MsCodeCoverageCollectionStatus.NotCollecting;
     runMsCodeCoverage = appOptionsProvider.Get().RunMsCodeCoverage;
     useMsCodeCoverage = runMsCodeCoverage == RunMsCodeCoverage.Yes;
     userRunSettingsProjectDetailsLookup = null;
     return(CleanUpAsync(testOperation));
 }
        private Mock <IMsCodeCoverageRunSettingsService> SetMsCodeCoverageCollecting(MsCodeCoverageCollectionStatus status = MsCodeCoverageCollectionStatus.Collecting)
        {
            var mockMsCodeCoverageRunSettingsService = mocker.GetMock <IMsCodeCoverageRunSettingsService>();

            mockMsCodeCoverageRunSettingsService.Setup(
                msCodeCoverageRunSettingsService =>
                msCodeCoverageRunSettingsService.IsCollectingAsync(It.IsAny <ITestOperation>())
                ).ReturnsAsync(status);

            SetUpOptions(mockOptions => mockOptions.Setup(options => options.Enabled).Returns(true));
            RaiseTestExecutionStarting();
            return(mockMsCodeCoverageRunSettingsService);
        }
Beispiel #5
0
        private async Task ProcessTemplateGenerationResultAsync(IProjectRunSettingsFromTemplateResult generationResult, List <ICoverageProject> coverageProjectsForShim)
        {
            if (generationResult.ExceptionReason == null)
            {
                await CollectingWithTemplateAsync(generationResult, coverageProjectsForShim);
            }
            else
            {
                var exceptionReason = generationResult.ExceptionReason;
                await CombinedLogExceptionAsync(exceptionReason.Exception, exceptionReason.Reason);

                collectionStatus = MsCodeCoverageCollectionStatus.Error;
            }
        }
Beispiel #6
0
        private async Task CollectingWithTemplateAsync(IProjectRunSettingsFromTemplateResult generationResult, List <ICoverageProject> coverageProjectsForShim)
        {
            coverageProjectsForShim.AddRange(generationResult.CoverageProjectsWithFCCMsTestAdapter);
            await CombinedLogAsync(() =>
            {
                var leadingMessage = generationResult.CustomTemplatePaths.Any() ? $"{msCodeCoverageMessage} - custom template paths" : msCodeCoverageMessage;
                var loggerMessages = new List <string> {
                    leadingMessage
                }.Concat(generationResult.CustomTemplatePaths.Distinct());
                logger.Log(loggerMessages);
                reportGeneratorUtil.LogCoverageProcess(msCodeCoverageMessage);
            });

            collectionStatus = MsCodeCoverageCollectionStatus.Collecting;
        }
        public void Should_Not_Delegate_To_UserRunSettingsService_When_Is_Not_Collecting(MsCodeCoverageCollectionStatus status)
        {
            msCodeCoverageRunSettingsService.collectionStatus = MsCodeCoverageCollectionStatus.NotCollecting;
            SetuserRunSettingsProjectDetailsLookup(false);

            ShouldNotDelegateToUserRunSettingsService(RunSettingConfigurationInfoState.Execution);
        }
Beispiel #8
0
 private Task ExceptionAnalysingUserRunSettingsAsync(Exception exc)
 {
     collectionStatus = MsCodeCoverageCollectionStatus.Error;
     return(CombinedLogExceptionAsync(exc, "Exception analysing runsettings files"));
 }
        public void Should_Notify_MsCodeCoverage_When_Test_Execution_Not_Finished_IfCollectingAsync(MsCodeCoverageCollectionStatus status, bool cancelling)
        {
            var mockMsCodeCoverageRunSettingsService = SetMsCodeCoverageCollecting(status);
            var operation = new Mock <IOperation>().Object;
            var mockTestOperationFactory = mocker.GetMock <ITestOperationFactory>();
            var testOperation            = new Mock <ITestOperation>().Object;

            mockTestOperationFactory.Setup(testOperationFactory => testOperationFactory.Create(operation)).Returns(testOperation);

            RaiseOperationStateChanged(
                cancelling ? TestOperationStates.TestExecutionCanceling : TestOperationStates.TestExecutionCancelAndFinished,
                operation
                );
            var times = status == MsCodeCoverageCollectionStatus.Collecting ? Times.Once() : Times.Never();

            mockMsCodeCoverageRunSettingsService.Verify(
                msCodeCoverageRunSettingsService => msCodeCoverageRunSettingsService.TestExecutionNotFinishedAsync(testOperation), times
                );
        }