What is the different between Unit Testing and Block Testing? They both seem to cover the same section of code. I'm writing a Test Approach report. The PM wants answers to these categories.
I don't think block testing is a commonly accepted term. What you are probably referring to is block coverage.
Unit testing is a TYPE of testing, where the smallest 'units' in an application are tested in isolation. This often means testing individual methods in a class, with mocked or stubbed external dependencies.
One level higher than a unit testing is integration testing, which is meant to test the interaction between different groups of code together. This can be relatively shallow by just testing a combination of several classes, or it can be broader in the sense that you store data in a running database.
In any type of test, you might be interested in how much of a certain section of code is covered by any type of test. The simplest form is line coverage where you measure the percentage of code lines that have been executed after all tests were run. This example here shows how block coverage works:
You can measure the coverage for both unit and integration tests.
This question is kind of like asking "what's the difference between apples and red delicious?" They aren't mutually exclusive. :)
Unit testing is a broad category of tests that are generally short, fast, and isolated (the code being tested has few or no dependencies, such as an individual method).
Block coverage is a metric you might use to evaluate your overall unit test coverage, or a technique you might use to help you increase your coverage when writing new unit tests. As I commented above, this answer to a question about block coverage gives a very good summary of what block coverage is and how it differs from statement coverage, which is a more, well, apples to apples, comparison.
Unit Testing is testing of unit/module of the code. A project may consist of various units/modules. Testing the units in isolation to check whether they work fine is known as Unit Testing. Unit Testing is generally done by developers, but not necessarily the developer who wrote the modules/units.
A Block Testing is testing done on a block of code. For example, testing a sub-class of a higher class, or testing some lines of code work properly or not. Block testing is done by the developer of the code, as he/she may have a better understanding of the code written by them.
As you know, Unit Testing is often a simple assert statement for a specific line of code. (ie "b = 1 + 1; assert(b==2)").
Block Testing is often concerned about covering both sides of a conditional statement. For example, if your program has an if/else statement then testing the "if" block would be one half of the coverage and the "else" statement would be the other half. Bear in mind that block testing is not limited to if/else statements but could be applied to case statements, elseif statements, etc. Basically, block coverage testing is done to ensure that blocks of code aren't left untested by failing to test all paths of a conditional statement.