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

Allow to inherit from fixture methods #1680

Open
gao-artur opened this issue May 24, 2023 · 2 comments · May be fixed by #4677
Open

Allow to inherit from fixture methods #1680

gao-artur opened this issue May 24, 2023 · 2 comments · May be fixed by #4677

Comments

@gao-artur
Copy link

gao-artur commented May 24, 2023

Hey. We have integrated OpenTelemetry using System.Diagnostics.ActivitySource in our services and now looking to improve observability in the end-to-end tests. We are using MsTest to run different scenarios, including calling web services (with OTel support), sending bus messages, accessing databases, etc.
We want to achieve the following with as less duplicate code as possible:

  • Assembly Initialize:
    • create a new ActivitySource
    • wrap the method logic with an Activity
  • Assembly Cleanup:
    • wrap the method logic with an Activity
    • dispose the ActivitySource created on Assembly Initialize
  • Class Initialize/Cleanup: wrap the method logic with an Activity
  • Test method: wrap the method logic with an Activity

The last point looks pretty simple. It can be achieved by deriving the TestMethodAttribute and overriding the Execute method. And by deriving from TestClassAttribute and overriding the GetTestMethodAttribute, we can simply replace the [TestClass] with our [TelemetryTestClass] and finish the task with minimal changes.
But unfortunately, it's impossible to do the same with Assembly and Class Initialize/Cleanup attributes.
Are there any extension points that would allow implementing it once and reusing it in all assemblies/classes? If not, would you consider providing such extension points in future releases?

AB#2332773

@Evangelink
Copy link
Member

@gao-artur I have changed the title of your issue as for now we will only allow to derive the fixture attributes so you can achieve the feature yourself. I still strongly want to provide a built-in Open Telemetry feature but we will need more design time.

@Evangelink
Copy link
Member

Blocking for now the progress on this because we need to agree on direction to take as first implementation is unveiling quite some questions. We first have to decide if we want to allow to provide only a before and after functionality or offer a "invoke" functionnality. After that, we need to decide what to do for things like timeout (e.g. is [Timeout] only applying to the user method and so the before/after or code wrapping it in case of invoke not part of the timeout or is it?), what about special scheduling like STA.

There are also some questions regarding the impact/difference of behavior when having a sync vs async method where things like Culture would (or would not) flow down.

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

Successfully merging a pull request may close this issue.

4 participants