Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for IMessageSink #246

Merged
merged 14 commits into from
Oct 2, 2021
Merged

Conversation

0xced
Copy link
Contributor

@0xced 0xced commented Oct 1, 2021

This enables logging in extensibility classes such as fixtures and discoverers. See https://xunit.net/docs/capturing-output#output-in-extensions for more information.

All classes were modeled after the similar classes for ITestOutputHelper. The only method impossible to replicate was public static ILoggingBuilder AddXUnit(this ILoggingBuilder builder).

This enables logging in extensibility classes such as fixtures and discoverers. See https://xunit.net/docs/capturing-output#output-in-extensions for more information.

All classes were modeled after the similar classes for `ITestOutputHelper`. The only method impossible to replicate was `public static ILoggingBuilder AddXUnit(this ILoggingBuilder builder)`.
@codecov
Copy link

codecov bot commented Oct 1, 2021

Codecov Report

Merging #246 (144c55a) into main (bedd07b) will decrease coverage by 1.25%.
The diff coverage is 95.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #246      +/-   ##
==========================================
- Coverage   99.12%   97.87%   -1.26%     
==========================================
  Files           8       15       +7     
  Lines         342      517     +175     
==========================================
+ Hits          339      506     +167     
- Misses          3       11       +8     
Flag Coverage Δ
linux 97.87% <95.85%> (-1.26%) ⬇️
macos 97.87% <95.85%> (-1.26%) ⬇️
windows 97.87% <95.85%> (-1.26%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...g.XUnit/XUnitLoggerExtensions.ITestOutputHelper.cs 100.00% <ø> (ø)
src/Logging.XUnit/XUnitLogger.IMessageSink.cs 88.88% <88.88%> (ø)
src/Logging.XUnit/XUnitLoggerProvider.cs 94.44% <88.88%> (-5.56%) ⬇️
...ogging.XUnit/XUnitLoggerExtensions.IMessageSink.cs 95.12% <95.12%> (ø)
src/Logging.XUnit/IMessageSinkExtensions.cs 100.00% <100.00%> (ø)
src/Logging.XUnit/MessageSinkAccessor.cs 100.00% <100.00%> (ø)
src/Logging.XUnit/XUnitLogger.ITestOutputHelper.cs 100.00% <100.00%> (ø)
src/Logging.XUnit/XUnitLogger.cs 98.13% <100.00%> (+0.08%) ⬆️
src/Logging.XUnit/XUnitLoggerOptions.cs 100.00% <100.00%> (ø)
.../Logging.XUnit/XUnitLoggerProvider.IMessageSink.cs 100.00% <100.00%> (ø)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bedd07b...144c55a. Read the comment docs.

@martincostello martincostello added the enhancement New feature or request label Oct 2, 2021
Copy link
Owner

@martincostello martincostello left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good - just a few comments.

Directory.Packages.props Outdated Show resolved Hide resolved
src/Logging.XUnit/XUnitLogger.IMessageSink.cs Outdated Show resolved Hide resolved
src/Logging.XUnit/XUnitLogger.IMessageSink.cs Outdated Show resolved Hide resolved
src/Logging.XUnit/XUnitLogger.IMessageSink.cs Show resolved Hide resolved
src/Logging.XUnit/XUnitLogger.cs Show resolved Hide resolved
src/Logging.XUnit/XUnitLoggerProvider.cs Outdated Show resolved Hide resolved
src/Logging.XUnit/XUnitLoggerProvider.cs Outdated Show resolved Hide resolved
tests/Logging.XUnit.Tests/Integration/DatabaseFixture.cs Outdated Show resolved Hide resolved
tests/Logging.XUnit.Tests/xunit.runner.json Show resolved Hide resolved
0xced and others added 13 commits October 2, 2021 14:58
xunit.abstractions 2.0.2 and xunit.extensibility.execution 2.4.0 are the first versions to support .NET Standard 2.0
Co-authored-by: Martin Costello <martin@martincostello.com>
Co-authored-by: Martin Costello <martin@martincostello.com>
Co-authored-by: Martin Costello <martin@martincostello.com>
Co-authored-by: Martin Costello <martin@martincostello.com>
Co-authored-by: Martin Costello <martin@martincostello.com>
Co-authored-by: Martin Costello <martin@martincostello.com>
@0xced
Copy link
Contributor Author

0xced commented Oct 2, 2021

Thanks for your excellent code review, I hope I addressed all your concerns.

@martincostello
Copy link
Owner

Thanks for this change @0xced!

I'm doing to do few tests to bump the code coverage up a bit now I've been shamed by the bot, and then I'll prep a new release with this change in it by the end of Monday.

@martincostello martincostello merged commit ea86954 into martincostello:main Oct 2, 2021
@martincostello martincostello added this to the v0.1.3 milestone Oct 2, 2021
@0xced 0xced deleted the IMessageSink branch October 2, 2021 17:37
@0xced
Copy link
Contributor Author

0xced commented Oct 2, 2021

Awesome! 🥳

After you increase the code coverage, you might want to try mutation testing with Stryker Mutator. This could reveal that even with a high coverage the tests might not test as much as you'd think.

Here's a quick how-to:

cd tests/Logging.XUnit.Tests
dotnet new tool-manifest
dotnet tool install dotnet-stryker --version 1.0.0-rc3
echo '{"stryker-config":{"project":"MartinCostello.Logging.XUnit.csproj"}}' > stryker-config.json
dotnet stryker

I just tried and the current score is 68.81 % so there's some room for improvement. 😉

@martincostello
Copy link
Owner

Tada: https://www.nuget.org/packages/MartinCostello.Logging.XUnit/0.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants