Skip to content

Commit d7f7c86

Browse files
committed
1.0.0: ToJson for TestResult
1 parent ebf1273 commit d7f7c86

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</PropertyGroup>
66

77
<PropertyGroup Label="NuGetPublishSettings">
8-
<NuGetPublishVersion>0.9.0</NuGetPublishVersion>
8+
<NuGetPublishVersion>1.0.0</NuGetPublishVersion>
99
<NuGetPublishVersionSuffix></NuGetPublishVersionSuffix>
1010
<!-- relative path from .csproj files, without trailing slash -->
1111
<NuGetPublishProjectRootRelPath>..</NuGetPublishProjectRootRelPath>

src/FUnit.TestResult.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using FUnitImpl;
2+
using Jsonable;
23
using System;
34
using System.Collections.Generic;
45
using System.ComponentModel;
@@ -8,21 +9,21 @@
89
partial class FUnit
910
#pragma warning restore CA1050
1011
{
11-
// TODO: JSON-convertible
12-
1312
/// <summary>
1413
/// Represents the result of a test run.
1514
/// </summary>
1615
[EditorBrowsable(EditorBrowsableState.Never)] // should not be included in IntelliSense suggestion
17-
public sealed class TestResult
16+
[ToJson]
17+
public sealed partial class TestResult
1818
{
1919
/// <summary>
2020
/// Represents an error that occurred during a test case execution.
2121
/// </summary>
2222
/// <param name="Message">The error message.</param>
2323
/// <param name="StackTrace">The stack trace where the error occurred.</param>
2424
/// <param name="IsFUnitError">Indicates whether the error occurred outside the scope of 'describe' or 'it'.</param>
25-
public sealed record Error(string Message, string? StackTrace, bool IsFUnitError) { }
25+
[ToJson]
26+
public sealed partial record Error(string Message, string? StackTrace, bool IsFUnitError) { }
2627

2728
///// <summary>
2829
///// Represents a test subject.
@@ -39,7 +40,8 @@ public sealed record Error(string Message, string? StackTrace, bool IsFUnitError
3940
/// <param name="Description">The description of the test case.</param>
4041
/// <param name="ExecutionCount">The number of times the test case was executed.</param>
4142
/// <param name="Errors">The errors that occurred during the test case execution, if any.</param>
42-
public sealed record Test(string Description, int ExecutionCount, IReadOnlyList<Error>? Errors) { }
43+
[ToJson]
44+
public sealed partial record Test(string Description, int ExecutionCount, IReadOnlyList<Error>? Errors) { }
4345

4446

4547
/// <summary>

src/FUnit.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
<Pack>True</Pack><PackagePath>/</PackagePath>
1919
</None>
2020
</ItemGroup>
21+
<ItemGroup>
22+
<PackageReference Include="SatorImaging.Jsonable" Version="1.2.1">
23+
<PrivateAssets>all</PrivateAssets>
24+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
25+
</PackageReference>
26+
</ItemGroup>
2127
<PropertyGroup>
2228
<GenerateDocumentationFile>true</GenerateDocumentationFile>
2329
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>

tests/FUnit_test.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,17 @@ async ValueTask task()
213213
<details><summary><b>TEST</b>: <code>{nameof(FUnit)}.{nameof(FUnit.Result)}.{nameof(FUnit.Result.ToString)}()</code></summary>
214214
215215
```md
216-
217216
{resultText}
217+
```
218+
219+
</details>
220+
");
221+
222+
ConsoleLogger.LogInfoRaw($@"
223+
<details><summary><b>TEST</b>: <code>{nameof(FUnit)}.{nameof(FUnit.Result)}.{nameof(FUnit.Result.ToJson)}()</code></summary>
218224
225+
```json
226+
{FUnit.Result?.ToJson(prettyPrint: true)}
219227
```
220228
221229
</details>

0 commit comments

Comments
 (0)