How to re-use setups in multiple tests?

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <git@...>
Date: Monday, October 1, 2007 - 6:27 am

I'm wondering if there's a pattern for re-using setups across several
tests, similar to how a setUp function is used in xUnit. The problem
is I need the setup to actually be re-run, for each test to start from
a clean slate, so using the following doesn't work as the setup is
just run before the first test.

test_expect_success setup '
     # setup repostory to a particular state
'
test_expect_success test1 '
    # some test that expects the state to be as defined in setup, and
changes state of repository
'

test_expect_success test2 '
    # another test that expects the state to be as defined in setup
'

Is there a convention for doing this that's already used? Perhaps
pulling the setup code into a function or duplicating the code? Or is
it better to create a separate test file for tests that need to be
isolated?

Thanks,

-Tom
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
How to re-use setups in multiple tests?, Tom Clarke, (Mon Oct 1, 6:27 am)
Re: How to re-use setups in multiple tests?, Johannes Schindelin, (Mon Oct 1, 7:45 am)
Re: How to re-use setups in multiple tests?, Tom Clarke, (Mon Oct 1, 8:16 am)
Re: How to re-use setups in multiple tests?, Johannes Schindelin, (Mon Oct 1, 8:39 am)
Re: How to re-use setups in multiple tests?, Tom Clarke, (Mon Oct 1, 8:46 am)
Re: How to re-use setups in multiple tests?, Karl , (Mon Oct 1, 9:40 am)