Skip to main content
Tweeted twitter.com/StackProgrammer/status/739961775152582657
Copy edited (e.g. ref. <https://en.wiktionary.org/wiki/any_more#Adverb>).
Source Link

Are Integrationintegration tests meant to repeat all unit tests?

Let's say aI have a function (written in Ruby, but should be understandable by everyone):

def am_i_old_enougham_I_old_enough?(name = 'filip') person = Person::API.new(name) if person.male? return person.age > 21 else  return person.age > 18 end end 

In unit testing I would create 4four tests to cover all scenarios. Each will use mocked Person::API object with stubbed methods male? and age.

Now it comes to writing integration tests. I assume that Person::API should not be mocked anymoreany more. So I would create exactly the same 4four test cases, but without mocking Person::API object. Is that correct?

If yes, then what's the point of writing unit tests at all, if I could just write integration tests which give me more confidence (as I work on real objects, not stubs or mocks)?

Are Integration tests meant to repeat all unit tests?

Let's say a have a function (written in Ruby, but should be understandable by everyone):

def am_i_old_enough?(name = 'filip') person = Person::API.new(name) if person.male? return person.age > 21 else  return person.age > 18 end end 

In unit testing I would create 4 tests to cover all scenarios. Each will use mocked Person::API object with stubbed methods male? and age

Now it comes to writing integration tests. I assume that Person::API should not be mocked anymore. So I would create exactly the same 4 test cases but without mocking Person::API object. Is that correct?

If yes then what's the point of writing unit tests at all, if I could just write integration tests which give me more confidence (as I work on real objects, not stubs or mocks)

Are integration tests meant to repeat all unit tests?

Let's say I have a function (written in Ruby, but should be understandable by everyone):

def am_I_old_enough?(name = 'filip') person = Person::API.new(name) if person.male? return person.age > 21 else return person.age > 18 end end 

In unit testing I would create four tests to cover all scenarios. Each will use mocked Person::API object with stubbed methods male? and age.

Now it comes to writing integration tests. I assume that Person::API should not be mocked any more. So I would create exactly the same four test cases, but without mocking Person::API object. Is that correct?

If yes, then what's the point of writing unit tests at all, if I could just write integration tests which give me more confidence (as I work on real objects, not stubs or mocks)?

Source Link
Filip Bartuzi
  • 595
  • 1
  • 6
  • 13

Are Integration tests meant to repeat all unit tests?

Let's say a have a function (written in Ruby, but should be understandable by everyone):

def am_i_old_enough?(name = 'filip') person = Person::API.new(name) if person.male? return person.age > 21 else return person.age > 18 end end 

In unit testing I would create 4 tests to cover all scenarios. Each will use mocked Person::API object with stubbed methods male? and age

Now it comes to writing integration tests. I assume that Person::API should not be mocked anymore. So I would create exactly the same 4 test cases but without mocking Person::API object. Is that correct?

If yes then what's the point of writing unit tests at all, if I could just write integration tests which give me more confidence (as I work on real objects, not stubs or mocks)