开发者

Integration Testing vs. Unit Testing

I've recently 开发者_运维技巧started reading The Art of Unit Testing, and the light came on regarding the difference between Unit tests and Integration tests. I'm pretty sure there were some things I was doing in NUnit that would have fit better in an Integration test.

So my question is, what methods and tools do you use for Integration testing?


In my experience, you can use (mostly) the same tools for unit and integration testing. The difference is more in what you test, not how you test. So while setup, code tested and checking of results will be different, you can use the same tools.

For example, I have used JUnit and DBUnit for both unit and integration tests.

At any rate, the line between unit and integrations tests can be somewhat blurry. It depends on what you define as a "unit"...


Selenium along with Junit for unit+integration testing including the UI


Integration tests are the "next level" for people passionate about unit testing. Nunit itself can be used for integration testing(No tool change). eg scenario: A Unit test was created using Nunit using mock(where it goes to DB/API) To use integration test we do as follows

  1. instead of mocks use real DB

  2. leads to data input in DB

  3. leads to data corruption

  4. leads to deleting and recreating DB on every test

  5. leads to building a framework for data management(tool addition?)

As you can see from #2 onwards we are heading into an unfamiliar territory as unit test developers. Even though the tool remains the same.

  1. leads to you wondering, why so much time for integration test setup?
  2. leads to : shall I stop unit testing as both kinds of tests takes more time?
  3. leads to : we only do integration testing
  4. leads to : would all devs agree to this? (some devs might hate testing altogether)
  5. leads to : since no unit test, no code coverage.

Now we are heading to issues with business goals and dev physco..

I think I answered your question a bit more than needed. Anyways, like to read more and you think unit tests are a danger? then head to this


1) Method: Test Point Metrics is best approach in any environment. By this approach not only we can do unit and integration testing but also validate the requirements. Time for writing Test Point Metrics is just after the Requirement understanding

A template of Test Point Metrics available here:

http://www.docstoc.com/docs/80205542/Test-Plan

Typically there are 3 kind of testing. 1. Manual 2. Automated 3. Hybrid approach

In all above cases Test Point Metrics approach works.

2) Tool: Tool will depend upon the requirements of project anyhow following are best tools according to my R&D 1. QTP 2. Selenium 3. AppPerfect For more clear answer about tool, please specify your type of project. Regards: Muhammad Husnain


I mostly use JUnit for unit testing in combination with Mockito to mock/stub out dependencies so i can test my unit of code in isolation.

For integration tests these are normally involve 'integration' with an external system/module like a database/message queue/framework etc... so to test these your best bet would be the use a combination of tools.

For e.g. i use JUnit as well but rather than mock out the dependencies i actually configure those dependencies as it were calling code. In addition, i test a flow of control so that each method are not tested in isolation as it is in Unit testing but instead together. Regarding Database connectivity, i use an embedded database with some dummy test data etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜