P
Peter Gummer
I want to perform some initialisation when an assembly is first loaded.
I know about static constructors, but that's not what I want. A class's
static constructor is not called until something uses the class at run
time. That may be too late.
What I'm actually trying to do is hook up a TraceListener so that calls
to Debug.Assert will throw an exception inside NUnit unit tests.
Because the DefaultTraceListener just pops up a dialog within the NUnit
GUI (which interrupts the unit tests), or else writes to the output
when run without a GUI (e.g. within the TestDriven.NET add-in), the
unit test in which the assertion failed is wrongly flagged as having
succeeded. NUnit needs an exception. I intend to supply that exception
by writing a TraceListener that will be hooked up by my unit tests. I
could hook it up in, say, the SetUp of my unit tests, or in their
static constructor, but what if I forget to do so for one of my test
fixture classes? I would rather do it once and for all on loading the
assembly that contains my unit tests.
But I can't figure out how!
Thanks,
Peter Gummer
I know about static constructors, but that's not what I want. A class's
static constructor is not called until something uses the class at run
time. That may be too late.
What I'm actually trying to do is hook up a TraceListener so that calls
to Debug.Assert will throw an exception inside NUnit unit tests.
Because the DefaultTraceListener just pops up a dialog within the NUnit
GUI (which interrupts the unit tests), or else writes to the output
when run without a GUI (e.g. within the TestDriven.NET add-in), the
unit test in which the assertion failed is wrongly flagged as having
succeeded. NUnit needs an exception. I intend to supply that exception
by writing a TraceListener that will be hooked up by my unit tests. I
could hook it up in, say, the SetUp of my unit tests, or in their
static constructor, but what if I forget to do so for one of my test
fixture classes? I would rather do it once and for all on loading the
assembly that contains my unit tests.
But I can't figure out how!
Thanks,
Peter Gummer