Ayende @ Rahien

Hi!
My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:

ayende@ayende.com

+972 52-548-6969

, @ Q c

Posts: 11 | Comments: 40

filter by tags archive

Unit tests vs. Integration tests

time to read 1 min | 128 words

I can sum it up pretty easily:

Unit tests:
65 passed, 0 failed, 5 skipped, took 7.49 seconds.

Integration tests:
45 passed, 0 failed, 0 skipped, took 284.43 seconds.

Except, there is one thing that you aren’t seeing here. Writing an integration tests is about as straightforward as they come. Execute the user scenario, assert the result. There is no real knowledge required to write the test, and they are very easy to read and understand.

Unit tests, however, often require you to understand how the software work in much finer detail, and they often make no sense to someone who isn’t familiar with the software.


Comments

John Chapman

Am I the only one that finds it shocking that 65 unit tests took 7.49 seconds to run? Based on that timing it sounds like the unit tests may be doing more than expected. I'm used to 65 unit tests taking a fraction of a second.

What kind of work are your unit tests doing? It almost seems like they would need some level of "integration" to make them that slow.

Igor Tamaschuk

And you are right. Moreover, every newbie in the test driven approach going to write the integration tests in first order. Especially if he is not strong enough in OOD and his design is like a one big transaction script with GOTOs :)

Ayende Rahien

John,

That number also include the time to spin up the test framework, but yes, they are oing a lot

Paulo Aboim Pinto

I have this two levels of tests too. Usually the unit test mock the next layer (example testing Business Layer and mock the Data Access Layer).

In the integration test I will run some database scripts to create the database initial state and run the integration tests that will do on Business layer and I will not mock the DAL. The test will go to the end of the chain .. to the database.

this is the way that I do.. and that's why the integration tests take more time then the unit tests (in my case).

Regards

Paulo Aboim Pinto

Odivelas - Portugal

Comment preview

Comments have been closed on this topic.

FUTURE POSTS

  1. Production postmortem: The case of the lying configuration file - one day from now
  2. Production postmortem: The industry at large - about one day from now
  3. The insidious cost of allocations - 3 days from now
  4. Find the bug: The concurrent memory buster - 4 days from now
  5. Buffer allocation strategies: A possible solution - 7 days from now

And 3 more posts are pending...

There are posts all the way to Sep 10, 2015

RECENT SERIES

  1. Find the bug (5):
    20 Apr 2011 - Why do I get a Null Reference Exception?
  2. Production postmortem (10):
    31 Aug 2015 - The case of the memory eater and high load
  3. What is new in RavenDB 3.5 (7):
    12 Aug 2015 - Monitoring support
  4. Career planning (6):
    24 Jul 2015 - The immortal choices aren't
View all series

Syndication

Main feed Feed Stats
Comments feed   Comments Feed Stats