Re: nunit tests hold onto file handles after testsaredone

"Pigneri, Rocco" <[email protected]>
Newsgroups gmane.comp.windows.dotnet.nunit.user
Message-ID <D04B62A56C65EA4B860036108BD0A66C0258E9A7@boston-ex.lavastorm.local.com>
In order to do this I need to be able to "ask for the name of the test
which is about to run, or just finished running, from SetUp or
TearDown", and "ask for the pass/fail result of the last test when in
TearDown", alternatively, if there is a way to ask for the pass/fail
result of any test by name, I could use the first result about the test
name and then look up the test result. 



Another possible way to solve this problem is to have the SetUp both
tear down the old test bed and build the new one.  That way, all of your
test output will be available after the run of the tests, thus allowing
you to inspect all the test output on a whim.  The one downfall to this
is that your test beds will be left around after your tests are run,
which may not work in your situation.

 

A side bonus of this setup is that any failures in your test setups will
not cause your tests to fail repeatedly on the following runs.  This
scenario is most commonly experienced when testing the database.  If
your SetUp inserts data into the database, and your SetUp fails, then
the TearDown is not run, and your test data is not removed from the
database.  In this case, the next run of your tests could fail due to
duplicate inserts.  

 

Hope that helps,

 

Rocco 

 

From: [email protected]
[mailto:[email protected]] On Behalf Of David
Jeske
Sent: Thursday, June 19, 2008 7:37 PM
To: Charlie Poole
Cc: [email protected]
Subject: Re: [Nunit-users] nunit tests hold onto file handles after
testsaredone

 

On Thu, Jun 19, 2008 at 11:10 AM, Charlie Poole
<[email protected]> wrote:

	NUnit does have some current problems of not releasing objects,
which are fixed in the source. Some of those /could/ relate to your file
problems, but there really is no guarantee that files not closed
explicitly will be closed between NUnit runs. This makes some kinds of
applications a bit hard to test. 


Reloading the project fixes my problems (presumably because it unloads
the assembly, which either accidentally, or deliberatly causes a GC).
However, the only setting in the nunit GUI is to "reload before each
test run". This is the opposite of what I want. I would need it to
"reload after the tests are complete", to force it to unload everything.
Is there some reason it can't do this? It might even be sufficient just
to force a full GC after it drops the handles to the instantiated test
objects. I suppose the right thing to do is hack the nunit gui source
and see if I can fix my problems. 
 

	The simplest way to do what you want for a test directory is to
delete and recreate it in SetUp or TestFixtureSetUp. In that case, it
will always be there between tests, whether they pass or not. If you
additionally want to delete some files when the tests pass, you
currently have to put the delete at the end of each test.


I see the SetUp/TearDown hooks, but I was hoping for something that
would let me get information about the test that is about to run or just
finished running. (what is it called, what was the result)

For example, I would create a setup which would create a fresh directory
with the same name as the test, and let the test run. Then in TearDown,
if the test passed, I would leave the directory in tact (so I could look
at the bad data inside it), but if the test passed, I would delete and
clean it up so it wasn't cluttering the directory.

In order to do this I need to be able to "ask for the name of the test
which is about to run, or just finished running, from SetUp or
TearDown", and "ask for the pass/fail result of the last test when in
TearDown", alternatively, if there is a way to ask for the pass/fail
result of any test by name, I could use the first result about the test
name and then look up the test result. 

How would I ask those questions in Nunit? or is there no way to do that?

Riddling my otherwise clean tests with a bunch of boilerplate finalizers
and junk just doesn't seem right.  Perhaps I'll look at making an
extension or patch if this can't be done today.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php

_______________________________________________
Nunit-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nunit-users
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.