[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Test::Unit and one-time setup and teardown

Ara Vartanian

2/27/2007 8:25:00 PM

Does anyone know of a way of performing one-time setup and teardown per Test::Unit::TestCase?I have an integration test with an external component where, unfortunately, mocking out a server response is not feasible. So I need to mount a servlet to interact with my test. It would be pointless and slow to do this once for every test method. I know other unit testing frameworks define such callbacks. Does Test::Unit? If not, is there a clever way of getting around it? I am using Rails's 'test/helper', so I'm not instantiating my own test harness. Obviously, I can setup any needed resources in the class scope of the unit test itself, BUT that still doesn't give me a callback for teardown.Any ideas?Thanks for your help.-- Ara Vartanian ____________________________________________________________________________________Yahoo! Music UnlimitedAccess over 1 million songs.http://music.yahoo.com...

12 Answers

Robert Dober

2/27/2007 9:47:00 PM

0

On 2/27/07, Ara Vartanian <ara_vartanian@yahoo.com> wrote:
> Does anyone know of a way of performing one-time setup and teardown per Test::Unit::TestCase?
>
> I have an integration test with an external component where, unfortunately, mocking out a server response is not feasible. So I need to mount a servlet to interact with my test. It would be pointless and slow to do this once for every test method. I know other unit testing frameworks define such callbacks. Does Test::Unit? If not, is there a clever way of getting around it?
>
> I am using Rails's 'test/helper', so I'm not instantiating my own test harness. Obviously, I can setup any needed resources in the class scope of the unit test itself, BUT that still doesn't give me a callback for teardown

Eric Hodel

2/27/2007 11:17:00 PM

0

On Feb 27, 2007, at 12:25, Ara Vartanian wrote:

> Does anyone know of a way of performing one-time setup and teardown
> per Test::Unit::TestCase?

Do it at class level and store it in a class variable or constant.

> I have an integration test with an external component where,
> unfortunately, mocking out a server response is not feasible. So I
> need to mount a servlet to interact with my test. It would be
> pointless and slow to do this once for every test method. I know
> other unit testing frameworks define such callbacks. Does
> Test::Unit? If not, is there a clever way of getting around it?

I don't believe you. I've tested complex interactions with a stub'd
Net::HTTP. See rc_rest/uri_stub.rb and rc_rest/net_http_stub.rb.

> I am using Rails's 'test/helper', so I'm not instantiating my own
> test harness. Obviously, I can setup any needed resources in the
> class scope of the unit test itself, BUT that still doesn't give me
> a callback for teardown.

at_exit {
at_exit {
# your teardown
}
}




Mat Schaffer

2/28/2007 3:55:00 AM

0

On Feb 27, 2007, at 3:25 PM, Ara Vartanian wrote:
> Does anyone know of a way of performing one-time setup and teardown
> per Test::Unit::TestCase?
>
> I have an integration test with an external component where,
> unfortunately, mocking out a server response is not feasible. So I
> need to mount a servlet to interact with my test. It would be
> pointless and slow to do this once for every test method. I know
> other unit testing frameworks define such callbacks. Does
> Test::Unit? If not, is there a clever way of getting around it?
>
> I am using Rails's 'test/helper', so I'm not instantiating my own
> test harness. Obviously, I can setup any needed resources in the
> class scope of the unit test itself, BUT that still doesn't give me
> a callback for teardown.
>
> Any ideas?

Have you tried BEGIN {} and END {}? But perhaps there's something
more graceful.
-Mat

Pit Capitain

2/28/2007 8:24:00 AM

0

Eric Hodel schrieb:
>
> at_exit {
> at_exit {
> # your teardown
> }
> }

Nice trick, Eric! Thanks for sharing.

Regards,
Pit

John Smith

10/31/2010 6:38:00 PM

0

On 10/31/2010 9:32 AM, WR wrote:

> ...
> How??? However bad the situation is, I'd always opt for a democratic
> ( I mean voting) solution, whoever is on top. Bad democracies are
> infinitely better than mob rule, dictators, or revolutionists.

You don't read history?

"Revolutionists" are who put this great democracy in place and upheld
it, until recently ... when, now, power seems to have been usurped from
the individuals who really are "the country", "the government" and the
only true holders of the right(s) to do so ...

No, I am not for allowing this country to become a "bad democracy", we
seem to have that now ... we don't need "leaders" we need the public
servants which the constitution sets up and gives rights to represent
the will of the people.

Regards,
JS

Wexford

10/31/2010 9:26:00 PM

0

On Oct 31, 2:38 pm, John Smith <assemblywiz...@gmail.com> wrote:
> On 10/31/2010 9:32 AM,WRwrote:
>
> > ...
> > How??? However bad the situation is, I'd always opt for a democratic
> > ( I mean voting) solution, whoever is on top. Bad democracies are
> > infinitely better than mob rule, dictators, or revolutionists.
>
> You don't read history?
>
> "Revolutionists" are who put this great democracy in place and upheld
> it, until recently ... when, now, power seems to have been usurped from
> the individuals who really are "the country", "the government" and the
> only true holders of the right(s) to do so ...
>
> No, I am not for allowing this country to become a "bad democracy", we
> seem to have that now ... we don't need "leaders" we need the public
> servants which the constitution sets up and gives rights to represent
> the will of the people.
>
> Regards,
> JS

The American Revolution was about disengaging from British rule, not
about overthrowing government. The colonists wanted to retain their
colonial governments, sans Royal governors, and rule themselves. For
example, when the Royal Governor of Virginia disbanded the Virginia
House of Burgesses, they simply reconvened in a Tavern and plotted
joining with the other colonies to oust the useless British, who taxed
but didn't defend, who controlled all aspects of colonial economics,
who kept colonials in debt and bled the colonies white. In addition,
the British had forbidden Western expansion beyond what is now Eastern
Ohio, limiting opportunities. In any event, that revolution was about
retaining local democratic-republican forms, about local rule, and
about cutting the cord with the Mother Country. Remember, when the
Whiskey Rebellion challenged the Federal Government of the young
United States, President George Washington donned his old uniform
himself and led the federal troops who suppressed it.

The Rightwing (and Leftwing) nutcases who start posturing with threats
of violent revolution today are all about destroying Government. That
type of revolution almost invariably leads to excess and finally to
dictatorship. We're nowhere near that point, of course. For the most
part, the American people are sane and responsible. There is anger and
frustration out there but not enough to force a rebellion.

John Smith

10/31/2010 11:08:00 PM

0

On 10/31/2010 2:25 PM, WR wrote:

>> ...

Yes, it serves only as an example, times change, crimes, tactis, etc.
changes ... this time it will be about tossing criminal-treasonous
public servants out of office who serve the bankster and wall street
puppet masters ... it will be about dismantling the fed, it will be
about destroying the debt system, etc. ...

Regards,
JS

dave

11/1/2010 2:14:00 PM

0

WR wrote:
> On Oct 31, 2:38 pm, John Smith<assemblywiz...@gmail.com> wrote:

>
> The Rightwing (and Leftwing) nutcases who start posturing with threats
> of violent revolution today are all about destroying Government. That
> type of revolution almost invariably leads to excess and finally to
> dictatorship. We're nowhere near that point, of course. For the most
> part, the American people are sane and responsible. There is anger and
> frustration out there but not enough to force a rebellion.

The government has already been overthrown. That was obvious last summer
when Obama was taking orders from BP. The USA is dead. They cleaned
out the bank on their way out of town. Hurry, the trail is getting cold.

Yoorghis

11/1/2010 2:35:00 PM

0

On Mon, 01 Nov 2010 06:13:54 -0800, dave <dave@dave.dave> wrote:

>The government has already been overthrown. That was obvious last summer
>when Obama was taking orders from BP. The USA is dead.

Then you're in for a huge surprise----after republicans start raping
your dead carcass.

Just like they used to do.

RHF

11/1/2010 10:09:00 PM

0

A Crossroads Election -means- You Have A 'Choice' :

Go Left -or- Go Right

=OR= Even Go Straight Ahead In The Same Direction
{Steady The Course !}

At A Crossroads --- All Ways Are 'Possible' :
It's Your 'Choice' & It's Your 'Vote'

Just "VOTE" ! ~ RHF
.
.
On Nov 1, 7:35 am, Yoorg...@Jurgis.net wrote:
> On Mon, 01 Nov 2010 06:13:54 -0800, dave <d...@dave.dave> wrote:
- - The government has already been overthrown.
- - That was obvious last summer when Obama was
- - taking orders from BP.

Yeah Prez Obama Surrendered the US Federal
Government to BP and for that the Obama [BP]
Oil Spill in the Gulf when on and on and on
for over 90 Days . . .
.
The Great Obama [BP] Oil Spill of 20&10
http://groups.google.com/group/alt.politics.liberalism/msg/e2713a...
.
Prez Obama -releases- The 'Barack Petroleum'
[BP] Report . . . Spills The Beans -oops- Oil ;-}
http://groups.google.com/group/rec.radio.shortwave/msg/2fc626...
.
- - The USA is dead.

ONLY *IF* YOU LET IT DIE !
.
- Then you're in for a huge surprise----
- after republicans start raping your dead carcass.
-
- Just like they used to do.

That's an Obama-Bot© Reply

You Can't Continually Win Elections by Denigrating and
Disparaging Half to 2/3rds of the American People :
Who Are Persons of Faith and Love Their Country ~ RHF
.
Prez Obama preaches disdain for Average Hard
Working Americans across the Nation because
They Cling to Their Guns and Religion . . .
http://www.youtube.com/watch?v=h...
Just Where Is Barack "_" Obama Faith :
When He Disrespects People of Faith Publicly ?
http://www.youtube.com/watch?v=D...
.
Obama-Bots© -aka- The "O"Borg©
=WRT= “Fifty Cent Party,” the “Red Vests” and
the “Red Vanguard.” But Obama’s growing armies
of Web commentators {Political Cadre}— instigated,
trained and financed by far left party organizations
[Soros]
http://groups.google.com/group/rec.radio.shortwave/msg/170a84...
-by- "Chas. Chan" <tianmei...@gmail.com>
.
Obama-Bots© "We Are The Obama"© The "O"Borg©
http://groups.google.com/group/rec.radio.shortwave/msg/3812f6...
.
.