Re: (MaxTimeDecorator) Instance fields initialized by TestFixtureSetUp are null when test runs

"Charlie Poole" <[email protected]>
Newsgroups gmane.comp.windows.dotnet.nunit.user
Message-ID <013d01c823c0$7abfeaf0$6401a8c0@FERRARI>
For production use, Test Decorators require a LOT of work when they are 
implemented as a separate test that wraps the original test. Every
setting in the origial test must be replicated in the wrapper or the
calls must be forwarded. The sample doesn't do this, since it's just
a simple example, but the comments should really make this clear.

Note that test decorators can be implemented in other ways: either
returning a completely new test or modifying properties of the 
original test. Either of these approaches is actually much simpler
than the wrapper approach shown in the sample.

Eventually, we'll have more samples and more clear extensive
samples.

Charlie

> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf 
> Of Joseph A. Davidson
> Sent: Friday, November 09, 2007 12:12 PM
> To: '[email protected]'
> Subject: [Nunit-users] (MaxTimeDecorator) Instance fields 
> initialized by TestFixtureSetUp are null when test runs
> 
> See attached file.
> Using NUnit 2.4.2 on XP SP2/.NET 2.0, the null checks for 
> "list" fail in both tests when the MaxTimeDecorator add-in is 
> installed.
> 
> When using a derived TestCase to run tests (like the 
> MaxTimeDecorator sample), it seems like it creates a new 
> instance of the class for each test, so the non-static fields 
> are set back to null.
> 
> We made an add-in very similar to the MaxTimeDecorator sample 
> that runs a test and does some custom handling after the test 
> has run. The ITestDecorator.Decorate() method is setup to 
> create a new TestCase-derived object for every method with 
> TestAttribute.
> 
> We have hundreds of existing test fixtures that follow a 
> pattern of initializing fields in the TestFixtureSetUp and 
> using those objects in each test. This issue can be resolved 
> by making these objects static, but I'd like to solve this 
> without modifying the tests themselves.
> 
> Thanks,
> 
> Joe
> 
> 



-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.