Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Stravaig Contributors
Copyright (c) 2020 Stravaig Projects' Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 1 addition & 0 deletions release-notes/wip-release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Date: ???
- #179: Update github pages pipeline.
- #181: Add support for .NET 9.0.
- #183: Update github action workflow to separate the build and deploy stages.
- #185: Add package readme to the XUnit extensions package

### Dependencies

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
<Title>XUnit extensions for Stravaig Logging Capture for Tests</Title>
<Version>$(STRAVAIG_NUGET_VERSION)</Version>
<Authors>Colin Angus Mackay</Authors>
<Copyright>©$2023-(YEAR) Colin Angus Mackay. See licence for more information.</Copyright>
<Copyright>©2023-$(YEAR) Colin Angus Mackay. See licence for more information.</Copyright>
<PackageProjectUrl>https://stravaig-projects.github.io/Stravaig.Extensions.Logging.Diagnostics/</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryUrl>https://github.com/Stravaig-Projects/Stravaig.Extensions.Logging.Diagnostics</RepositoryUrl>
<PackageIcon>stravaig-icon.png</PackageIcon>
<PackageTags>logging testing xunit</PackageTags>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageReadmeFile>readme.md</PackageReadmeFile>
<Description>
XUnit extensions for Stravaig Logging Capture for Tests.

Expand All @@ -29,6 +30,10 @@
<Pack>true</Pack>
<PackagePath>/</PackagePath>
</None>
<None Include="readme.md">
<Pack>True</Pack>
<PackagePath>/</PackagePath>
</None>
</ItemGroup>

<!-- Source link properties -->
Expand Down
45 changes: 45 additions & 0 deletions src/Stravaig.Extensions.Logging.Diagnostics.XUnit/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# About

XUnit extensions for [Stravaig Log Capture](https://www.nuget.org/packages/Stravaig.Extensions.Logging.Diagnostics/) add helper extension methods for outputting the captured logs via XUnit's `IOutputTestHelper`.

## Version & Framework support

* v2.x: Supports .NET 6.0, 7.0 & 8.0
* v3.x: Supports .NET 6.0, 8.0 & 9.0


## How to use

For simple tests you can pass the logger into the class under test like this:

```csharp
public class MyTestClass
{
private readonly IOutputTestHelper _output;

public MyTestClass(IOutputTestHelper output)
{
_output = output;
}

[Fact]
public void EnsureSomeFunctionalityWorks()
{
// Arrange
var logger = new TestCaptureLogger<ServiceClass>();
var service = new ServiceClass(logger);

// Act
service.DoSomething();

// Assert
_output.WriteLogs(logger); // Writes all captured logs to the output.
logger.GetLogs().Count.ShouldBe(1);
}
}
```

## See also

* [Full Documentation](https://stravaig-projects.github.io/Stravaig.Extensions.Logging.Diagnostics/docs/library/xunit-extensions.html)
* [Release Notes](https://github.com/Stravaig-Projects/Stravaig.Extensions.Logging.Diagnostics/releases)
5 changes: 4 additions & 1 deletion src/Stravaig.Extensions.Logging.Diagnostics/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@ public void EnsureSomeFunctionalityWorks()
}
```

For more details on more complex scenarios, see the full documentation at https://stravaig-projects.github.io/Stravaig.Extensions.Logging.Diagnostics/
## See also

* [Full Documentation](https://stravaig-projects.github.io/Stravaig.Extensions.Logging.Diagnostics/)
* [Release Notes](https://github.com/Stravaig-Projects/Stravaig.Extensions.Logging.Diagnostics/releases)