Skip to content
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

Docs on creating extensions #4365

Open
thomhurst opened this issue Dec 16, 2024 · 1 comment
Open

Docs on creating extensions #4365

thomhurst opened this issue Dec 16, 2024 · 1 comment

Comments

@thomhurst
Copy link
Contributor

This page shows what microsoft extensions are currently available: https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-platform-extensions

But I cannot find a how-to on writing my own.

For example, I don't even know if this is possible with extensions, but I'd like to:

  • Register an extension
  • When my test suite finishes, my extension is passed information about that test suite
  • That extension checks if we're running in GitHub actions
  • If we are, it writes to the OUTPUT_SUMMARY file with an easy-to-read table of the results
@Youssef1313
Copy link
Member

If I correctly understand what you need, I think what you need builder.TestHost.AddTestSessionLifetimeHandle(new YourExtension());

This will notify you when the test session ended. In addition, you can also implement IDataConsumer (and use builder.TestHost.AddDataConsumer) to get information on tests while they run so that you can accumulate this information at the end when you get the OnTestSessionFinishingAsync callback.

This is documented in https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-platform-architecture-extensions#the-itesthostprocesslifetimehandler-extensions and https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-platform-architecture-extensions#the-idataconsumer-extensions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants