Merge pull request #1523 from livarcocc/debug_tests_abstractions

Adding a TestRunner.TestCompleted message to the test sinks.
This commit is contained in:
Livar 2016-02-22 19:45:03 -08:00
commit 06d31435cb
7 changed files with 49 additions and 17 deletions

View file

@ -3,7 +3,7 @@
namespace Microsoft.Extensions.Testing.Abstractions namespace Microsoft.Extensions.Testing.Abstractions
{ {
public interface ITestDiscoverySink public interface ITestDiscoverySink : ITestSink
{ {
void SendTestFound(Test test); void SendTestFound(Test test);
} }

View file

@ -3,7 +3,7 @@
namespace Microsoft.Extensions.Testing.Abstractions namespace Microsoft.Extensions.Testing.Abstractions
{ {
public interface ITestExecutionSink public interface ITestExecutionSink : ITestSink
{ {
void SendTestStarted(Test test); void SendTestStarted(Test test);

View file

@ -0,0 +1,10 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
namespace Microsoft.Extensions.Testing.Abstractions
{
public interface ITestSink
{
void SendTestCompleted();
}
}

View file

@ -6,7 +6,7 @@ using Newtonsoft.Json;
namespace Microsoft.Extensions.Testing.Abstractions namespace Microsoft.Extensions.Testing.Abstractions
{ {
class LineDelimitedJsonStream public class LineDelimitedJsonStream
{ {
private readonly StreamWriter _stream; private readonly StreamWriter _stream;

View file

@ -4,13 +4,10 @@ using Newtonsoft.Json.Linq;
namespace Microsoft.Extensions.Testing.Abstractions namespace Microsoft.Extensions.Testing.Abstractions
{ {
public class StreamingTestDiscoverySink : ITestDiscoverySink public class StreamingTestDiscoverySink : StreamingTestSink, ITestDiscoverySink
{ {
private readonly LineDelimitedJsonStream _stream; public StreamingTestDiscoverySink(Stream stream) : base(stream)
public StreamingTestDiscoverySink(Stream stream)
{ {
_stream = new LineDelimitedJsonStream(stream);
} }
public void SendTestFound(Test test) public void SendTestFound(Test test)
@ -20,7 +17,7 @@ namespace Microsoft.Extensions.Testing.Abstractions
throw new ArgumentNullException(nameof(test)); throw new ArgumentNullException(nameof(test));
} }
_stream.Send(new Message Stream.Send(new Message
{ {
MessageType = "TestDiscovery.TestFound", MessageType = "TestDiscovery.TestFound",
Payload = JToken.FromObject(test), Payload = JToken.FromObject(test),

View file

@ -1,3 +1,6 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.IO; using System.IO;
@ -5,18 +8,15 @@ using Newtonsoft.Json.Linq;
namespace Microsoft.Extensions.Testing.Abstractions namespace Microsoft.Extensions.Testing.Abstractions
{ {
public class StreamingTestExecutionSink : ITestExecutionSink public class StreamingTestExecutionSink : StreamingTestSink, ITestExecutionSink
{ {
private readonly LineDelimitedJsonStream _stream;
private readonly ConcurrentDictionary<string, TestState> _runningTests; private readonly ConcurrentDictionary<string, TestState> _runningTests;
public StreamingTestExecutionSink(Stream stream) : base(stream)
public StreamingTestExecutionSink(Stream stream)
{ {
_stream = new LineDelimitedJsonStream(stream);
_runningTests = new ConcurrentDictionary<string, TestState>(); _runningTests = new ConcurrentDictionary<string, TestState>();
} }
public void SendTestStarted(Test test) public void SendTestStarted(Test test)
{ {
if (test == null) if (test == null)
@ -30,7 +30,7 @@ namespace Microsoft.Extensions.Testing.Abstractions
_runningTests.TryAdd(test.FullyQualifiedName, state); _runningTests.TryAdd(test.FullyQualifiedName, state);
} }
_stream.Send(new Message Stream.Send(new Message
{ {
MessageType = "TestExecution.TestStarted", MessageType = "TestExecution.TestStarted",
Payload = JToken.FromObject(test), Payload = JToken.FromObject(test),
@ -57,7 +57,7 @@ namespace Microsoft.Extensions.Testing.Abstractions
testResult.EndTime = DateTimeOffset.Now; testResult.EndTime = DateTimeOffset.Now;
} }
_stream.Send(new Message Stream.Send(new Message
{ {
MessageType = "TestExecution.TestResult", MessageType = "TestExecution.TestResult",
Payload = JToken.FromObject(testResult), Payload = JToken.FromObject(testResult),

View file

@ -0,0 +1,25 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.IO;
namespace Microsoft.Extensions.Testing.Abstractions
{
public abstract class StreamingTestSink : ITestSink
{
protected LineDelimitedJsonStream Stream { get; }
protected StreamingTestSink(Stream stream)
{
Stream = new LineDelimitedJsonStream(stream);
}
public void SendTestCompleted()
{
Stream.Send(new Message
{
MessageType = "TestRunner.TestCompleted"
});
}
}
}