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: 5,972 | Comments: 44,525

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

No future posts left, oh my!

RECENT SERIES

  1. Production postmortem (5):
    29 Jul 2015 - The evil licensing code
  2. Career planning (6):
    24 Jul 2015 - The immortal choices aren't
  3. API Design (7):
    20 Jul 2015 - We’ll let the users sort it out
  4. What is new in RavenDB 3.5 (3):
    15 Jul 2015 - Exploring data in the dark
  5. The RavenDB Comic Strip (3):
    28 May 2015 - Part III – High availability & sleeping soundly
View all series

Syndication

Main feed Feed Stats
Comments feed   Comments Feed Stats