Skip to content

Commit

Permalink
add logging to the Fine Code Coverage tool window (#227)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
tonyhallett authored Feb 13, 2022
1 parent 57ab677 commit 9967ac4
Show file tree
Hide file tree
Showing 29 changed files with 1,434 additions and 206 deletions.
4 changes: 4 additions & 0 deletions FineCodeCoverage/FineCodeCoverage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@
<Link>Resources\LICENSE</Link>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="..\Shared Files\Resources\dummyReportToProcess.html">
<Link>Resources\dummyReportToProcess.html</Link>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="..\Shared Files\Resources\reportparts.xml">
<Link>Resources\reportparts.xml</Link>
<IncludeInVSIX>true</IncludeInVSIX>
Expand Down
4 changes: 4 additions & 0 deletions FineCodeCoverage2022/FineCodeCoverage2022.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
<Link>OutputToolWindowPackage.vsct</Link>
<ResourceName>Menus.ctmenu</ResourceName>
</VSCTCompile>
<Content Include="..\Shared Files\Resources\dummyReportToProcess.html">
<Link>Resources\dummyReportToProcess.html</Link>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="..\Shared Files\Resources\reportparts.xml">
<Link>Resources\reportparts.xml</Link>
<IncludeInVSIX>true</IncludeInVSIX>
Expand Down
61 changes: 3 additions & 58 deletions FineCodeCoverageTests/FCCEngine_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,44 +342,6 @@ public async Task Should_Not_Process_ReportGenerator_Output_If_Failure()

}

[Test]
public async Task Should_Clear_UI_Then_Update_UI_When_ReloadCoverage_Completes_Fully()
{
fccEngine.CoverageLines = new List<CoverageLine>();
var (reportGeneratedHtmlContent, updatedCoverageLines) = await RunToCompletion(false);

VerifyLogsReloadCoverageStatus(ReloadCoverageStatus.Done);

VerifyClearUIEvents(0);

Assert.AreSame(updatedCoverageLines, updateMarginTagsCoverageLines[1]);
Assert.AreEqual(reportGeneratedHtmlContent, updateOutputWindowEvents[1].HtmlContent);

}

[Test]
public async Task Should_Clear_UI_When_ReloadCoverage_And_No_CoverageProjects()
{
fccEngine.CoverageLines = new List<CoverageLine>();

await RunToCompletion(true);

VerifyLogsReloadCoverageStatus(ReloadCoverageStatus.Done);

Assert.Null(updateMarginTagsCoverageLines[1]);
Assert.Null(updateOutputWindowEvents[1].HtmlContent);
}

[Test]
public async Task Should_Update_OutputWindow_With_Null_HtmlContent_When_Reading_Report_Html_Throws()
{
await ThrowReadingReportHtml();

Assert.AreEqual(updateMarginTagsCoverageLines[1].Count, 1);
Assert.Null(updateOutputWindowEvents[1].HtmlContent);

}

[Test]
public async Task Should_Log_Single_Exception_From_Aggregate_Exception()
{
Expand All @@ -389,30 +351,13 @@ public async Task Should_Log_Single_Exception_From_Aggregate_Exception()
mocker.Verify<ILogger>(l => l.Log(exception));
}

[Test]
public async Task Should_Clear_UI_When_There_Is_An_Exception()
{
fccEngine.CoverageLines = new List<CoverageLine>();
await ThrowException();
VerifyClearUIEvents(1);
}

[Test]
public async Task Should_Cancel_Running_Coverage_Logging_Cancelled_When_StopCoverage()
{
await StopCoverage();
VerifyLogsReloadCoverageStatus(ReloadCoverageStatus.Cancelled);
}

[Test]
public async Task Should_Not_Update_UI_When_ReloadCoverage_Is_Cancelled()
{
await StopCoverage();
Assert.AreEqual(1, updateMarginTagsEvents.Count);
Assert.AreEqual(1, updateOutputWindowEvents.Count);

}

[Test]
public async Task Should_Cancel_ProcessUtil_Tasks_When_StopCoverage()
{
Expand Down Expand Up @@ -450,7 +395,7 @@ public async Task Should_Cancel_Existing_ReloadCoverage_When_ReloadCoverage()
Thread.Sleep(1000);
t.Start();
}).Returns(Task.CompletedTask);
}).Returns(Task.FromResult(new CoverageProjectFileSynchronizationDetails()));

await ReloadInitializedCoverage(mockSuitableCoverageProject.Object);
VerifyLogsReloadCoverageStatus(ReloadCoverageStatus.Cancelled);
Expand Down Expand Up @@ -554,7 +499,7 @@ private async Task StopCoverage()
{
fccEngine.StopCoverage();
}).Returns(Task.CompletedTask);
}).Returns(Task.FromResult(new CoverageProjectFileSynchronizationDetails()));

await ReloadInitializedCoverage(mockSuitableCoverageProject.Object);
}
Expand Down Expand Up @@ -585,7 +530,7 @@ private Mock<ICoverageProject> CreateSuitableProject()
var mockSuitableCoverageProject = new Mock<ICoverageProject>();
mockSuitableCoverageProject.Setup(p => p.ProjectFile).Returns("Defined.csproj");
mockSuitableCoverageProject.Setup(p => p.Settings.Enabled).Returns(true);
mockSuitableCoverageProject.Setup(p => p.PrepareForCoverageAsync()).Returns(Task.CompletedTask);
mockSuitableCoverageProject.Setup(p => p.PrepareForCoverageAsync()).Returns(Task.FromResult(new CoverageProjectFileSynchronizationDetails()));
mockSuitableCoverageProject.Setup(p => p.StepAsync("Run Coverage Tool", It.IsAny<Func<ICoverageProject, Task>>())).Returns(Task.CompletedTask);
return mockSuitableCoverageProject;
}
Expand Down
11 changes: 0 additions & 11 deletions FineCodeCoverageTests/TestContainerDiscovery_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,5 @@ public void Should_Handle_Any_Exception_In_OperationState_Changed_Handler_Loggin
RaiseTestExecutionCancelling();
mocker.Verify<ILogger>(logger => logger.Log("Error processing unit test events", exception));
}

[TestCase(true)]
[TestCase(false)]
public void Should_Clear_UI_When_Enabled_Setting_Is_Set_To_False(bool newEnabled)
{
var mockAppOptions = new Mock<IAppOptions>();
mockAppOptions.Setup(o => o.Enabled).Returns(newEnabled);
mocker.GetMock<IAppOptionsProvider>().Raise(optionsProvider => optionsProvider.OptionsChanged += null, mockAppOptions.Object);
mocker.Verify<IFCCEngine>(engine => engine.ClearUI(), newEnabled ? Times.Never() : Times.Once());

}
}
}
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@

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

Download this extension from the [Visual Studio Market Place](https://marketplace.visualstudio.com/items?itemName=FortuneNgwenya.FineCodeCoverage)
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)
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).

---------------------------------------
---
Prerequisites

Only that the test adapters are nuget packages. For instance, the NUnit Test Adapter extension is not sufficient.
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.
---------------------------------------

---

Introduction

Fine Code Coverage works by reacting to the visual studio test explorer, providing coverage from each test project containing tests that you have selected
to run. This coverage is presented as a single unified report as well as coloured margins alongside your code.
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.
This coverage is not dynamic and represents the coverage obtained from the last time you executed tests.
When the coverage becomes outdated, you can click the 'FCC Clear UI' button in Tools or run coverage again.

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.

The coverage is provided by either [OpenCover](https://github.com/OpenCover/opencover) for old style projects and [Coverlet](https://github.com/coverlet-coverage/coverlet)
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
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.
Expand All @@ -28,7 +31,7 @@ but there may be a preview version that you want to use. This can be configured
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
can only be set in project files.

---------------------------------------
---

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

Expand Down
Loading

0 comments on commit 9967ac4

Please sign in to comment.