Skip to content

Commit 9967ac4

Browse files
authored
add logging to the Fine Code Coverage tool window (#227)
* add logging to the Fine Code Coverage tool window * Fine Code Coverage link to FCC Output Window Pane * Ensure output window is open before activating FCC pane. * refactor responsibilities * Use font and colors / environment font both for font-family and font-size in combination with dpi. * delete test that does not apply anymore
1 parent 57ab677 commit 9967ac4

29 files changed

+1434
-206
lines changed

FineCodeCoverage/FineCodeCoverage.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@
7373
<Link>Resources\LICENSE</Link>
7474
<IncludeInVSIX>true</IncludeInVSIX>
7575
</Content>
76+
<Content Include="..\Shared Files\Resources\dummyReportToProcess.html">
77+
<Link>Resources\dummyReportToProcess.html</Link>
78+
<IncludeInVSIX>true</IncludeInVSIX>
79+
</Content>
7680
<Content Include="..\Shared Files\Resources\reportparts.xml">
7781
<Link>Resources\reportparts.xml</Link>
7882
<IncludeInVSIX>true</IncludeInVSIX>

FineCodeCoverage2022/FineCodeCoverage2022.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@
6565
<Link>OutputToolWindowPackage.vsct</Link>
6666
<ResourceName>Menus.ctmenu</ResourceName>
6767
</VSCTCompile>
68+
<Content Include="..\Shared Files\Resources\dummyReportToProcess.html">
69+
<Link>Resources\dummyReportToProcess.html</Link>
70+
<IncludeInVSIX>true</IncludeInVSIX>
71+
</Content>
6872
<Content Include="..\Shared Files\Resources\reportparts.xml">
6973
<Link>Resources\reportparts.xml</Link>
7074
<IncludeInVSIX>true</IncludeInVSIX>

FineCodeCoverageTests/FCCEngine_Tests.cs

Lines changed: 3 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -342,44 +342,6 @@ public async Task Should_Not_Process_ReportGenerator_Output_If_Failure()
342342

343343
}
344344

345-
[Test]
346-
public async Task Should_Clear_UI_Then_Update_UI_When_ReloadCoverage_Completes_Fully()
347-
{
348-
fccEngine.CoverageLines = new List<CoverageLine>();
349-
var (reportGeneratedHtmlContent, updatedCoverageLines) = await RunToCompletion(false);
350-
351-
VerifyLogsReloadCoverageStatus(ReloadCoverageStatus.Done);
352-
353-
VerifyClearUIEvents(0);
354-
355-
Assert.AreSame(updatedCoverageLines, updateMarginTagsCoverageLines[1]);
356-
Assert.AreEqual(reportGeneratedHtmlContent, updateOutputWindowEvents[1].HtmlContent);
357-
358-
}
359-
360-
[Test]
361-
public async Task Should_Clear_UI_When_ReloadCoverage_And_No_CoverageProjects()
362-
{
363-
fccEngine.CoverageLines = new List<CoverageLine>();
364-
365-
await RunToCompletion(true);
366-
367-
VerifyLogsReloadCoverageStatus(ReloadCoverageStatus.Done);
368-
369-
Assert.Null(updateMarginTagsCoverageLines[1]);
370-
Assert.Null(updateOutputWindowEvents[1].HtmlContent);
371-
}
372-
373-
[Test]
374-
public async Task Should_Update_OutputWindow_With_Null_HtmlContent_When_Reading_Report_Html_Throws()
375-
{
376-
await ThrowReadingReportHtml();
377-
378-
Assert.AreEqual(updateMarginTagsCoverageLines[1].Count, 1);
379-
Assert.Null(updateOutputWindowEvents[1].HtmlContent);
380-
381-
}
382-
383345
[Test]
384346
public async Task Should_Log_Single_Exception_From_Aggregate_Exception()
385347
{
@@ -389,30 +351,13 @@ public async Task Should_Log_Single_Exception_From_Aggregate_Exception()
389351
mocker.Verify<ILogger>(l => l.Log(exception));
390352
}
391353

392-
[Test]
393-
public async Task Should_Clear_UI_When_There_Is_An_Exception()
394-
{
395-
fccEngine.CoverageLines = new List<CoverageLine>();
396-
await ThrowException();
397-
VerifyClearUIEvents(1);
398-
}
399-
400354
[Test]
401355
public async Task Should_Cancel_Running_Coverage_Logging_Cancelled_When_StopCoverage()
402356
{
403357
await StopCoverage();
404358
VerifyLogsReloadCoverageStatus(ReloadCoverageStatus.Cancelled);
405359
}
406360

407-
[Test]
408-
public async Task Should_Not_Update_UI_When_ReloadCoverage_Is_Cancelled()
409-
{
410-
await StopCoverage();
411-
Assert.AreEqual(1, updateMarginTagsEvents.Count);
412-
Assert.AreEqual(1, updateOutputWindowEvents.Count);
413-
414-
}
415-
416361
[Test]
417362
public async Task Should_Cancel_ProcessUtil_Tasks_When_StopCoverage()
418363
{
@@ -450,7 +395,7 @@ public async Task Should_Cancel_Existing_ReloadCoverage_When_ReloadCoverage()
450395
Thread.Sleep(1000);
451396
t.Start();
452397

453-
}).Returns(Task.CompletedTask);
398+
}).Returns(Task.FromResult(new CoverageProjectFileSynchronizationDetails()));
454399

455400
await ReloadInitializedCoverage(mockSuitableCoverageProject.Object);
456401
VerifyLogsReloadCoverageStatus(ReloadCoverageStatus.Cancelled);
@@ -554,7 +499,7 @@ private async Task StopCoverage()
554499
{
555500
fccEngine.StopCoverage();
556501

557-
}).Returns(Task.CompletedTask);
502+
}).Returns(Task.FromResult(new CoverageProjectFileSynchronizationDetails()));
558503

559504
await ReloadInitializedCoverage(mockSuitableCoverageProject.Object);
560505
}
@@ -585,7 +530,7 @@ private Mock<ICoverageProject> CreateSuitableProject()
585530
var mockSuitableCoverageProject = new Mock<ICoverageProject>();
586531
mockSuitableCoverageProject.Setup(p => p.ProjectFile).Returns("Defined.csproj");
587532
mockSuitableCoverageProject.Setup(p => p.Settings.Enabled).Returns(true);
588-
mockSuitableCoverageProject.Setup(p => p.PrepareForCoverageAsync()).Returns(Task.CompletedTask);
533+
mockSuitableCoverageProject.Setup(p => p.PrepareForCoverageAsync()).Returns(Task.FromResult(new CoverageProjectFileSynchronizationDetails()));
589534
mockSuitableCoverageProject.Setup(p => p.StepAsync("Run Coverage Tool", It.IsAny<Func<ICoverageProject, Task>>())).Returns(Task.CompletedTask);
590535
return mockSuitableCoverageProject;
591536
}

FineCodeCoverageTests/TestContainerDiscovery_Tests.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -227,16 +227,5 @@ public void Should_Handle_Any_Exception_In_OperationState_Changed_Handler_Loggin
227227
RaiseTestExecutionCancelling();
228228
mocker.Verify<ILogger>(logger => logger.Log("Error processing unit test events", exception));
229229
}
230-
231-
[TestCase(true)]
232-
[TestCase(false)]
233-
public void Should_Clear_UI_When_Enabled_Setting_Is_Set_To_False(bool newEnabled)
234-
{
235-
var mockAppOptions = new Mock<IAppOptions>();
236-
mockAppOptions.Setup(o => o.Enabled).Returns(newEnabled);
237-
mocker.GetMock<IAppOptionsProvider>().Raise(optionsProvider => optionsProvider.OptionsChanged += null, mockAppOptions.Object);
238-
mocker.Verify<IFCCEngine>(engine => engine.ClearUI(), newEnabled ? Times.Never() : Times.Once());
239-
240-
}
241230
}
242231
}

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,26 @@
22

33
[![Build status](https://ci.appveyor.com/api/projects/status/yq8s0ridnphpx4ig?svg=true)](https://ci.appveyor.com/project/FortuneN/finecodecoverage)
44

5-
Download this extension from the [Visual Studio Market Place](https://marketplace.visualstudio.com/items?itemName=FortuneNgwenya.FineCodeCoverage)
5+
Download this extension from the [Visual Studio Market Place ( vs 2019 )](https://marketplace.visualstudio.com/items?itemName=FortuneNgwenya.FineCodeCoverage), [Visual Studio Market Place ( vs 2022 )](https://marketplace.visualstudio.com/items?itemName=FortuneNgwenya.FineCodeCoverage2022)
66
or download from [releases](https://github.com/FortuneN/FineCodeCoverage/releases). Older versions can be obtained from [here](https://ci.appveyor.com/project/FortuneN/finecodecoverage/history).
77

8-
---------------------------------------
8+
---
99
Prerequisites
1010

1111
Only that the test adapters are nuget packages. For instance, the NUnit Test Adapter extension is not sufficient.
1212
FCC will copy your test dll and dependencies to a sub folder this may affect your tests. The alternative is to set the option AdjacentBuildOutput to true.
13-
---------------------------------------
13+
14+
---
1415

1516
Introduction
1617

1718
Fine Code Coverage works by reacting to the visual studio test explorer, providing coverage from each test project containing tests that you have selected
18-
to run. This coverage is presented as a single unified report as well as coloured margins alongside your code.
19+
to run. This coverage is presented as a single unified report in the Fine Code Coverage Tool Window as well as coloured margins alongside your code.
1920
This coverage is not dynamic and represents the coverage obtained from the last time you executed tests.
2021
When the coverage becomes outdated, you can click the 'FCC Clear UI' button in Tools or run coverage again.
2122

23+
Details of how FCC is progressing with code coverage can be found in the Coverage Log tab in the Fine Code Coverage Tool Window with more detailed logs in the FCC Output Window Pane. If you experience issues then providing the logs from the output window will help to understand the nature of the problem.
24+
2225
The coverage is provided by either [OpenCover](https://github.com/OpenCover/opencover) for old style projects and [Coverlet](https://github.com/coverlet-coverage/coverlet)
2326
for new style sdk projects. FCC provides an abstraction over both so that it is possible to ignore the differences between the two but there are circumstances where
2427
it is important to be aware of cover tool that will be run. This is most apparent when Coverlet is used, please read on for the specifics.
@@ -28,7 +31,7 @@ but there may be a preview version that you want to use. This can be configured
2831
Configuration is available with Visual Studio settings and project msbuild properties. All visual studio settings can be overridden from test project settings and some settings
2932
can only be set in project files.
3033

31-
---------------------------------------
34+
---
3235

3336
### <a href="https://www.youtube.com/watch?v=Rae5bTE2D3o" target="_blank">Watch Introduction Video</a>
3437

0 commit comments

Comments
 (0)