On Aug 26, 2008, at 1:18 AM, Brice Figureau wrote:
>
> So you'll have to explain what is the difference between integration
> tests and unit tests, I'm a little bit confused. Maybe I'm trying to
> write an integration test in fact, without knowing it :-)
>
> My idea was to test that:
> 1) the daemontools provider implements the right interface (ie it
> respond_to the necessary methods)
> 2) the provider calls the right commands on start, stop, status
> 3) the provider creates/removes a symlink on enable/disable and
> properly checks its existence on enabled?

First, you'll never find a clean definition and you'll probably spend  
the rest of your life haunted by questions like this WRT testing.   
That being said...

A unit test essentially tests as small a chunk of functionality as  
possible.  It tests one class, and mocks out the interfaces to all  
other classes, as you mention below with the File.stubs stuff.  See  
Mocha (a ruby mock framework) for more info on how that works in  
Puppet's tests.

An integration test's job is to test the actual interaction between  
one or more classes.

Generally, a unit test would have plenty of mocking, and an  
integration test would have little or none.

As an example, I'm currently rewriting the fileserving code, and I've  
got a FileServing::Metadata class that has a ton of unit tests that  
use a mock File::Stat object.  When I go to an integration test,  
though, I needed to create a real file, since the system got too  
complicated to mock and I also couldn't really be *sure* it was  
working unless I wasn't doing any mocking.

>
> I agree that for 1) and 2), I don't need temporary files/directory.
> But for 3), I need to let the provider run in a controlled  
> environment,
> and later check it did its job, hence I need a few temporary
> directories.
>
> Note that I first wanted (and even tryed) to implement 3) by mocking
> File and FileTest to check that File.symlink and FileTest.symlink?  
> were
> called with the proper arguments, but of course that doesn't work.
> Oh, just had a look to some of the other spec and found that:
>        File.stubs(:exist?).returns(true)
>        File.expects(:unlink).with(@file)
>
> I think that answers my question :-)

Cool.

-- 
Aizu's Second Law:
     What changes the world is communication, not information.
---------------------------------------------------------------------
Luke Kanies | http://reductivelabs.com | http://madstop.com


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to