Discovery of hooks from shared assemblies #1496
danielmackay
started this conversation in
General
Replies: 2 comments 10 replies
-
|
This kinda relies on how the .NET runtime loads assemblies. If the assembly is loaded before test discovery, then hooks will be loaded and registered. Thing is with .NET, assemblies generally aren't loaded until they're first referenced. You can use a [Before(TestDiscovery)] hook and call a type from your assembly containing the hooks. Even just doing a console write line on a type from that assembly should load it in and fix your problem |
Beta Was this translation helpful? Give feedback.
7 replies
-
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there,
I have a solution with several test projects that I would like to share common setup code. This common setup code contains hooks to run code before any of the tests:
Project structure:

Shared test code:
However, I've noticed
GlobalSetup()will only get called if this class exists in the same test project the tests are contained in. I would like to be able to have this common setup code in one place, and re-used by all test projects, but currently this does not work.Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions