Injection of ITestOutputHelper in test class #2205
-
Hello xunit team and community, I wonder if there are other ways to get the instance of the ITestOutputHelper interface in a test class besides the available Constructor injection option. Background: After updating xUnit in my existing project the established logging via Log4Net does not work within the tests anymore. Therefore a TestOutputHelper instance is now required. If you use Constructor injection for this purpose, all test classes within my existing project must be adapted accordingly. In this case it would be desirable to get the TestOutputHelper instance directly in a test base class (e.g. via property injection or a static help method of xUnit). An adaptation of the derived test classes would therefore not be necessary. My question: Does such an approach exist? Thank you for each answer, a good time and greetings |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
There is no other way today in v2, without heroic measures. We are planning support for a test context in v3: #621 There is an unsupported third party version of this available today for v2. I haven't tried it, but it's spoken well of. https://github.com/SimonCropp/XunitContext |
Beta Was this translation helpful? Give feedback.
There is no other way today in v2, without heroic measures.
We are planning support for a test context in v3: #621
There is an unsupported third party version of this available today for v2. I haven't tried it, but it's spoken well of. https://github.com/SimonCropp/XunitContext