Skip to content

Commit 70a40c9

Browse files
committed
Move ResultReporter to nunit.common
1 parent b2f97d3 commit 70a40c9

File tree

7 files changed

+16
-23
lines changed

7 files changed

+16
-23
lines changed

src/NUnitConsole/nunit4-console.tests/ResultReporterTests.cs renamed to src/NUnitCommon/nunit.common.tests/TextDisplay/ResultReporterTests.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@
55
using System.IO;
66
using System.Text;
77
using System.Xml;
8-
using NUnit.ConsoleRunner.Options;
98
using NUnit.Engine;
109
using NUnit.Framework;
1110
using NUnit.Framework.Api;
1211
using NUnit.TestData.Assemblies;
13-
using NUnit.TextDisplay;
1412

15-
namespace NUnit.ConsoleRunner
13+
namespace NUnit.TextDisplay
1614
{
1715
public class ResultReporterTests
1816
{
@@ -51,7 +49,7 @@ public void CreateReporter()
5149
{
5250
_report = new StringBuilder();
5351
var writer = new ExtendedTextWrapper(new StringWriter(_report));
54-
_reporter = new ResultReporter(_result, writer, ConsoleMocks.Options());
52+
_reporter = new ResultReporter(_result, writer);
5553
}
5654

5755
[Test]

src/NUnitCommon/nunit.common.tests/nunit.common.tests.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10+
<ProjectReference Include="..\..\TestData\mock-assembly\mock-assembly.csproj" />
1011
<ProjectReference Include="..\nunit.common\nunit.common.csproj" />
1112
<ProjectReference Include="..\..\NUnitEngine\nunit.engine.api\nunit.engine.api.csproj" />
1213
</ItemGroup>

src/NUnitConsole/nunit4-console/ResultReporter.cs renamed to src/NUnitCommon/nunit.common/TextDisplay/ResultReporter.cs

+10-13
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt
22

33
using System;
4-
using System.Collections.Generic;
54
using System.Globalization;
65
using System.Xml;
7-
using NUnit.ConsoleRunner.Options;
8-
using NUnit.TextDisplay;
96

10-
namespace NUnit.ConsoleRunner
7+
namespace NUnit.TextDisplay
118
{
129
public class ResultReporter
1310
{
14-
public ResultReporter(XmlNode resultNode, ExtendedTextWriter writer, ConsoleOptions options)
11+
public ResultReporter(XmlNode resultNode, ExtendedTextWriter writer, bool stopOnError = false)
1512
{
1613
ResultNode = resultNode;
1714
Writer = writer;
18-
Options = options;
15+
StopOnError = stopOnError;
1916

2017
string? overallResult = resultNode.GetAttribute("result");
2118
if (overallResult == "Skipped")
@@ -32,8 +29,8 @@ public ResultReporter(XmlNode resultNode, ExtendedTextWriter writer, ConsoleOpti
3229
private int ReportIndex { get; set; }
3330
private XmlNode ResultNode { get; set; }
3431
private ExtendedTextWriter Writer { get; set; }
35-
private ConsoleOptions Options { get; set; }
3632
private string OverallResult { get; set; }
33+
private bool StopOnError { get; set; }
3734

3835
/// <summary>
3936
/// Reports the results to the console
@@ -53,7 +50,7 @@ public void ReportResults()
5350
WriteSummaryReport();
5451
}
5552

56-
internal void WriteRunSettingsReport()
53+
public void WriteRunSettingsReport()
5754
{
5855
var firstSuite = ResultNode.SelectSingleNode("test-suite");
5956
if (firstSuite is not null)
@@ -150,11 +147,11 @@ public void WriteErrorsFailuresAndWarningsReport()
150147

151148
WriteErrorsFailuresAndWarnings(ResultNode);
152149

153-
if (Options.StopOnError)
154-
{
155-
Writer.WriteLine(ColorStyle.Failure, "Execution terminated after first error");
156-
Writer.WriteLine();
157-
}
150+
//if (Options.StopOnError)
151+
//{
152+
// Writer.WriteLine(ColorStyle.Failure, "Execution terminated after first error");
153+
// Writer.WriteLine();
154+
//}
158155
}
159156

160157
private void WriteErrorsFailuresAndWarnings(XmlNode resultNode)

src/NUnitConsole/nunit4-console.tests/BadFileTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public void MissingFileTest(string filename, string message)
3636
var result = runner.Run(this, TestFilter.Empty);
3737
var sb = new StringBuilder();
3838
var writer = new ExtendedTextWrapper(new StringWriter(sb));
39-
var reporter = new ResultReporter(result, writer, ConsoleMocks.Options());
39+
var reporter = new ResultReporter(result, writer);
4040

4141
reporter.WriteErrorsFailuresAndWarningsReport();
4242
var report = sb.ToString();

src/NUnitConsole/nunit4-console/ConsoleRunner.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ private int RunTests(TestPackage package, TestFilter filter)
271271

272272
if (result is not null)
273273
{
274-
var reporter = new ResultReporter(result, writer, _options);
274+
var reporter = new ResultReporter(result, writer, _options.StopOnError);
275275
reporter.ReportResults();
276276

277277
foreach (var spec in _options.ResultOutputSpecifications)

src/NUnitConsole/nunit4-console/TestEventHandler.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt
22

3-
using System;
43
using System.Xml;
54
using NUnit.Common;
65
using NUnit.Engine;
7-
using NUnit.TextDisplay;
86

9-
namespace NUnit.ConsoleRunner
7+
namespace NUnit.TextDisplay
108
{
119
/// <summary>
1210
/// TestEventHandler processes events from the running

src/NUnitConsole/nunit4-netcore-console/nunit4-netcore-console.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
<Compile Include="..\nunit4-console\Options\OutputSpecification.cs" Link="Options\OutputSpecification.cs" />
5151
<Compile Include="..\nunit4-console\Options\TestNameParser.cs" Link="Options\TestNameParser.cs" />
5252
<Compile Include="..\nunit4-console\RequiredExtensionException.cs" Link="RequiredExtensionException.cs" />
53-
<Compile Include="..\nunit4-console\ResultReporter.cs" Link="ResultReporter.cs" />
5453
<Compile Include="..\nunit4-console\TestEventHandler.cs" Link="TestEventHandler.cs" />
5554
<Compile Include="..\nunit4-console\Utilities\SaveConsoleOutput.cs" Link="Utilities\SaveConsoleOutput.cs" />
5655
<Content Include="..\..\..\LICENSE.txt" Link="LICENSE.txt" />

0 commit comments

Comments
 (0)