Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • @Steve, so in this example, would you say: one test for method 1, one test for method 2, and one test that runs 1 and 2 in the same test? Commented Apr 1, 2011 at 13:23
  • 2
    Yes. the first two would be unit tests, the third sounds like an integration test. Commented Apr 1, 2011 at 13:25
  • if you have customer module and orders module and order can't be created without relation to customer. How will you test it independent from customer module: create customer record in database with sql (insert into customer) or use Customer.createCustomer(). And IMHO use second one is better, as you don't need impelement any logic in test, but it works only if your test on creating customers pass. Commented Apr 1, 2011 at 13:28
  • @Dainius. In a unit test scenario you would typically use mock objects, so you would pass a mock customer to your order module. You are right in that you would not want to use sql in this case. Commented Apr 1, 2011 at 13:30
  • it seems that in any scenario where method B depends on method A, there will almost always be a method C that calls A then calls B. Since this is the case, you could test A, B, and C independently. Commented Apr 1, 2011 at 16:57