-
-
Notifications
You must be signed in to change notification settings - Fork 21
Add support for Microsoft.Testing.Platform
#53
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
Merged
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
38febc9
Migrate from `vstest` to `Microsoft.Testing.Platform` (#43)
Evangelink 3fe7b21
Format
Tyrrrz a2b5bd6
wip
Tyrrrz 3cd65bd
Format
Tyrrrz e42c6a6
asd
Tyrrrz ad398b2
asd
Tyrrrz d1c23fa
asd
Tyrrrz 09cb57f
asd
Tyrrrz 4e8b5df
Retrofit support for VSTest via an abstraction layer
Tyrrrz 0fa368d
asd
Tyrrrz ee603f1
asd
Tyrrrz 0ff54ee
asd
Tyrrrz b0959a1
asd
Tyrrrz 2a04ac6
asd
Tyrrrz b375377
asd
Tyrrrz c3baa5e
asd
Tyrrrz 7e73608
asd
Tyrrrz 1ec70f8
asd
Tyrrrz baa088e
asd
Tyrrrz e202765
asd
Tyrrrz 05fc4e5
asd
Tyrrrz 3896f9a
asd
Tyrrrz 4555bd6
asd
Tyrrrz d34bd30
asd
Tyrrrz 86232b4
asd
Tyrrrz d418098
asd
Tyrrrz d680c00
asd
Tyrrrz 1084ae2
MTP demo works
Tyrrrz af06bef
asd
Tyrrrz 23601ff
asd
Tyrrrz ed6a032
asd
Tyrrrz 201dcae
asd
Tyrrrz 460ef7b
Upgrade to MTP v2
Tyrrrz 77f8f51
asd
Tyrrrz 12e4e65
Merge
Tyrrrz ab562cc
asd
Tyrrrz c367f57
Use peer deps
Tyrrrz f4582b9
tests
Tyrrrz 80ff683
Async github interactions
Tyrrrz 65a9c48
Add MTP tests
Tyrrrz 3c4f5d5
asd
Tyrrrz 29a8325
asd
Tyrrrz b6a8c73
Migrate demo projects to MSTest
Tyrrrz b25749c
asd
Tyrrrz 423a9d9
asd
Tyrrrz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
wip
- Loading branch information
commit a2b5bd6f9299bb02d7d9631f4303e4a2c93bfdb0
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| using System.Collections.Generic; | ||
|
|
||
| namespace GitHubActionsTestLogger; | ||
|
|
||
| internal record TestDefinition( | ||
| string Id, | ||
| string DisplayName, | ||
| IReadOnlyDictionary<string, string> Properties | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| using Microsoft.Testing.Platform.Extensions.Messages; | ||
|
|
||
| namespace GitHubActionsTestLogger; | ||
|
|
||
| internal enum TestOutcome | ||
| { | ||
| None, | ||
| Passed, | ||
| Failed, | ||
| Skipped, | ||
| } | ||
|
|
||
| internal static class TestOutcomeExtensions | ||
| { | ||
| public static TestOutcome ToTestOutcome(this TestNodeStateProperty stateProperty) => | ||
| stateProperty switch | ||
| { | ||
| PassedTestNodeStateProperty => TestOutcome.Passed, | ||
| FailedTestNodeStateProperty => TestOutcome.Failed, | ||
| ErrorTestNodeStateProperty => TestOutcome.Failed, | ||
| TimeoutTestNodeStateProperty => TestOutcome.Failed, | ||
| SkippedTestNodeStateProperty => TestOutcome.Skipped, | ||
| CancelledTestNodeStateProperty => TestOutcome.Skipped, | ||
| _ => TestOutcome.None, | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| using System; | ||
| using System.Linq; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.Testing.Platform.CommandLine; | ||
| using Microsoft.Testing.Platform.Extensions.Messages; | ||
| using Microsoft.Testing.Platform.Extensions.TestHost; | ||
| using Microsoft.Testing.Platform.TestHost; | ||
|
|
||
| namespace GitHubActionsTestLogger; | ||
|
|
||
| /// <summary> | ||
| /// A Microsoft.Testing.Platform extension that reports test run information to GitHub Actions. | ||
| /// </summary> | ||
| internal class TestReporter(TestReporterExtension extension, ICommandLineOptions commandLineOptions) | ||
| : | ||
| // This is the extension point to subscribe to data messages published to the platform. | ||
| // The type should then be registered as a data consumer in the test host. | ||
| IDataConsumer, | ||
| // This is the extension point to subscribe to test session lifetime events. | ||
| // The type should then be registered as a test session lifetime handler in the test host. | ||
| ITestSessionLifetimeHandler | ||
| { | ||
| private readonly TestReporterContext _context = new( | ||
| GitHubWorkflow.Default, | ||
| TestReporterOptions.Resolve(commandLineOptions) | ||
| ); | ||
|
|
||
| public Type[] DataTypesConsumed { get; } = [typeof(TestNodeUpdateMessage)]; | ||
|
|
||
| public string Uid => extension.Uid; | ||
| public string Version => extension.Version; | ||
| public string DisplayName => extension.DisplayName; | ||
| public string Description => extension.Description; | ||
|
|
||
| public Task<bool> IsEnabledAsync() => extension.IsEnabledAsync(); | ||
|
|
||
| public Task ConsumeAsync( | ||
| IDataProducer dataProducer, | ||
| IData value, | ||
| CancellationToken cancellationToken | ||
| ) | ||
| { | ||
| if (value is not TestNodeUpdateMessage message) | ||
| throw new InvalidOperationException( | ||
| $"Unexpected data type: {value.GetType().FullName}" | ||
| ); | ||
|
|
||
| var state = message.TestNode.Properties.SingleOrDefault<TestNodeStateProperty>(); | ||
| if (state is null) | ||
| throw new InvalidOperationException("Test node state property is missing."); | ||
|
|
||
| _context.HandleTestResult( | ||
| new TestResult( | ||
| new TestDefinition( | ||
| message.TestNode.Uid.Value, | ||
| message.TestNode.DisplayName, | ||
| message | ||
| .TestNode.Properties.OfType<TestMetadataProperty>() | ||
| .ToDictionary(p => p.Key, p => p.Value) | ||
| ), | ||
| state.ToTestOutcome(), | ||
| state switch | ||
| { | ||
| FailedTestNodeStateProperty failedState => failedState.Exception, | ||
| ErrorTestNodeStateProperty errorState => errorState.Exception, | ||
| TimeoutTestNodeStateProperty timeoutState => timeoutState.Exception, | ||
| _ => null, | ||
| } | ||
| ) | ||
| ); | ||
|
|
||
| return Task.CompletedTask; | ||
| } | ||
|
|
||
| public Task OnTestSessionStartingAsync( | ||
| SessionUid sessionUid, | ||
| CancellationToken cancellationToken | ||
| ) => Task.CompletedTask; | ||
|
|
||
| public Task OnTestSessionFinishingAsync( | ||
| SessionUid sessionUid, | ||
| CancellationToken cancellationToken | ||
| ) | ||
| { | ||
| _context.HandleTestRunComplete(); | ||
| return Task.CompletedTask; | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.